Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python3 strings converted to bytes #4

Merged
merged 6 commits into from
Dec 9, 2015
Merged

Conversation

DarthJuri
Copy link
Contributor

optparse module still works, problem was in python3 unicode strings. It seems to work.

@cejkato2 cejkato2 merged commit e2ff4bf into CESNET:python3 Dec 9, 2015
@cejkato2
Copy link
Contributor

cejkato2 commented Dec 9, 2015

Merged, however, it still doesn't work...

In python3:

Traceback (most recent call last):
  File "python_example.py", line 58, in <module>
    UR_Flow = unirec.CreateTemplate("UR_Flow", fmtspec)
  File "/home/tomas/liberouter/nemea/nemea-framework/python/unirec/unirec.py", line 61, in CreateTemplate
    if isinstance(field_names, basestring):
NameError: name 'basestring' is not defined

According to oxplot/fysom#1 it can be solved by putting some additional lines.

In python2:

1353:(python3) python$ python python_example.py -i u:a,u:b
Traceback (most recent call last):
  File "python_example.py", line 28, in <module>
    parser # use previously defined OptionParser
  File "/home/tomas/liberouter/nemea/nemea-framework/python/trap.py", line 196, in CreateModuleInfo
    shortopt = c_char(bytes(o._short_opts[0][-1],'ascii'))
TypeError: str() takes at most 1 argument (2 given)
1354:(python3) python$ 

How to test it:

  1. I install nemea-framework and run python setup.py install and python3 setup.py install
  2. create a data file, e.g.:
 cat > myfile.csv <<KONEC
ipaddr DST_IP,ipaddr SRC_IP,uint16 SRC_PORT,uint16 DST_PORT
192.168.0.1,192.168.0.2,1234,80
192.168.0.2,192.168.0.1,80,1234
1.2.3.4,8.8.8.8,6853,53
KONEC
  1. run logger module from CESNET/Nemea-Modules:
./logger/logger -i u:b -t&
  1. run python_example.py:
python python_example.py -i u:a,u:b

or

python3 python_example.py -i u:a,u:b
  1. run logreplay module from CESNET/Nemea-Modules:
./logreplay/logreplay -i u:a -f myfile.csv -n

These steps should lead to replay of myfile.csv via python_example.py to logger.
Logger running in background should print received flow records.

@cejkato2 cejkato2 mentioned this pull request Dec 9, 2015
@DarthJuri DarthJuri mentioned this pull request Dec 18, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants