building and running mitmproxy in python windows: possible at all? - python

I was attempting to install mitmproxy and run the "mitmproxy" and "mitmdump" from the Scripts folder.
However, I get tons of errors that a lot of modules are not found.
From the error messages I tried to install all the missing modules
Pry
PyOpenSSL
Pyasn
urwid
I stopped after that as I am not sure this will lead me to success.
a) is running and building mitmproxy on windows possible at all?
b) how can I get all the dependant modules and install them?
I reached the point where the package "urwid" is needed. However that fails with: "Unable to find vcvarsall.bat"
EDIT: it seems running mitmproxy is not really possible as the urwid package provides the terminal GUI which does not work for windows. However, I only need mitmdump. When I try running it I get:
C:\Python27\Scripts>C:\Python27\python.exe mitmdump -w out.txt
Traceback (most recent call last): File "mitmdump", line 41, in <module>
proxyconfig = proxy.process_proxy_options(parser, options)
File "C:\Python27\lib\site-packages\libmproxy\proxy.py", line 527, in process_
proxy_options certutils.dummy_ca(cacert)
File "C:\Python27\lib\site-packages\libmproxy\certutils.py", line 44, in dummy_castdin=subprocess.PIPE
File "C:\Python27\lib\subprocess.py", line 493, in call
return Popen(*popenargs, **kwargs).wait()
File "C:\Python27\lib\subprocess.py", line 679, in __init__errread, errwrite)
File "C:\Python27\lib\subprocess.py", line 893, in _execute_childstartupinfo)
WindowsError: [Error 2] System can not find file
C:\Python27\Scripts>
Maybe it can not find this certificate dummy file that is created. However, it didnt create the "mitmproxy-ca-cert.p12"
Help needed

mitmproxy's console interface (ncurses) doesn't run on Windows, although you can get it running under Cygwin. If you don't need an interactive user interface for your specific task, mitmdump (comes with mitmproxy) gets the job done as well. If you want to try out some alpha-quality software, you can also try mitmproxy's mitmweb and open the webinterface at http://localhost:8081/.

Related

antiSMASH download_databases.py error in subprocess call

I am trying to intall antiSMASH on my research group's server but hitting an issue with the final stage of downloading the relevant databases. The makers provide a script "download_databases.py" to do this for you (see code at https://bitbucket.org/antismash/antismash/src/718da23d059742048bf044a1ed663806051eb0b2/download_databases.py?at=master&fileviewer=file-view-default).
Sadly there seems to be some kind of access issue (I'm not root and sudo doesn't help).
Server is RedHat CentOS 7.2.1511
Command run is "python download_databases.py" in antismash directory. Output is below:
Creating checksum of Pfam-A.hmm.gz
Extraction of Pfam-A.hmm.gz finished successfully.
Traceback (most recent call last):
File "download_databases.py", line 221, in <module>
main()
File "download_databases.py", line 198, in main
compile_pfam(filename)
File "download_databases.py", line 161, in compile_pfam
execute(command)
File "download_databases.py", line 51, in execute
stderr=subprocess.PIPE)
File "/usr/lib64/python2.7/subprocess.py", line 711, in __init__
errread, errwrite)
File "/usr/lib64/python2.7/subprocess.py", line 1327, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
Does anyone with experience of this have an idea of what I need to do? I've tried a local install of Python (2.7) where I have read/write access but that doesn't seem to help as the script is still looking elsewhere for the subprocess script (my own install is at the top of the PATH). Do I possibly need to install something extra with the local install or customise the install locations to include the subprocess etc stuff?
Thanks in advance. I'm no expert and really appreciate the help.
EDIT: Well I feel quite stupid now. Thanks to Hannu for suggesting I check $PATH and what binary the script was trying to execute. It turned out to be one of antiSMASH's dependencies (hmmpress) which I hadn't yet added to the $PATH on this machine. It hadn't occurred to me that it would be required prior to actually running antiSMASH.
Add print commands or something like that to your execute function and see what it tries to execute. The only explanation to get the error in that command is that the script or binary it tries to execute cannot be found.
Try adding a full path to your binary. That alone might solve the issue. Check that there are no typos in the command. Remember commands needs to be a list if it contains parameters, for example ["/usr/bin/foo/myprogram", "-a", "42", "-b", "/tmp/outputfile"] or whatever it is you need to pass to the program.

subprocess.check_call error in while trying to generate panoramic picture's for Pannellum

I'm using the Pannellum panorama viewer to do a tour experience of a campus. To improve the support for mobile devices I want to use the Pannellum's multiresolution format using the included python script to generate it form images.
I'm a mac user with very little python knowledge and gotten around to be able to execute the script from terminal (yay!)
The comments on the python script state the requirements:
# Requires Python 3.2+ (or Python 2.7), the Python Pillow package,
# and nona (from Hugin)
I'm running Python 2.7.10, I did install the Pillow package and got the
'nona' executable from the the 'HuginStitchProject.app' (From the package content) which was downloaded from their sourceforge mirror.
When executing the code with python generate.py basketball_court.jpg from the folder contaning the nona executable mentioned earlier, the *.jpg file and generate.py, I get the following error which I am not able to resolve:
Processing input image information...
Generating cube faces...
Traceback (most recent call last):
File "generate.py", line 106, in <module>
subprocess.check_call([args.nona, '-o', os.path.join(args.output, 'face'), os.path.join(args.output, 'cubic.pto')])
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 535, in check_call
retcode = call(*popenargs, **kwargs)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 522, in call
return Popen(*popenargs, **kwargs).wait()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1335, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
I see the OSError: [Errno 2] No such file or directory, which file am I missing? Which file is it unable to see?
Any help would be greatly appreciated :)
EDIT: I'm pretty sure that none executable I've got is not the dependency. I don't even know what a executable should look like. Should I be looking for a nona.py, nona.exe, nona.sh or something else?
subprocess.check_call is used to run something in the terminal, but looks like it cannot find the nona executable.
If you edit generate.py and put print(args.nona) before line 106, you'll see what it's trying to call.
Most likely you need to check paths, perhaps put the nona executable in the same dir as generate.py or the one you're running from. Also check it has the executable flag set.
Checking the generate.py source, I see it gets args.nona from its own parameters, or uses a default if you don't explicitly set it (line 59).
The default is set by trying to find an executable called "nona", else set it to None (line 37).

Running Linux Commands from Python on Windows Computer

I am trying to learn how to run command line commands from Python. I am able to do this with DOS:
import subprocess
subprocess.call("dir",shell=True)
This is fine, but I need to be able to do this for linux commands because my company uses linux servers. I am using Mobaxterm to run a local linux session. When I try this:
import subprocess
subprocess.call("ls",shell=True)
I get this error from the terminal:
'ls' is not recognized as an internal or external command, operable program or batch file.
Which sounds ridiculous to me, because ls is clearly a linux command.
If I don't include shell=True I get this error:
Traceback (most recent call last):
File "ConsolePractice.py", line 4, in <module>
subprocess.call("ls")
File "C:\Users\my_username\AppData\Local\Programs\Python\Python35-32\lib\subprocess.py", line 560, in call
with Popen(*popenargs, **kwargs) as p:
File "C:\Users\my_username\AppData\Local\Programs\Python\Python35-32\lib\subprocess.py", line 950, in __init__
restore_signals, start_new_session)
File "C:\Users\my_username\AppData\Local\Programs\Python\Python35-32\lib\subprocess.py", line 1220, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
So what am I doing wrong? How can I get this to work?
EDIT: Thanks for the comments. Python for Windows won't work for what I'm trying to do. I connected to a linux server and did:
cat > ConsoleCmd.py
import subprocess
subprocess.call("ls",shell=True)
^C
python ConsoleCmd.py
... and ls ran. Found the issue. I'll just have to get my scripts on to the server and run them from there. Thanks everyone
I was able to resolve this issue by opening an SFTP Session within Mobaxterm, transferring the python file to the server, then running the file directly on the server (python was already installed on the server).

Python - Pygame For android errors

I was following the documentation of pgs4a, where in the build part I got a WindowsError [Error 2].
The Command and Traceback:
C:\Users\karuna\Desktop\Jython\Python\pgs4a-0.9.4>android.py build "C:\Users\karuna\Desktop\Jython\P
ython\pgs4a-0.9.4\mygame" release install
Updating build files.
Traceback (most recent call last):
File "C:\Users\karuna\Desktop\Jython\Python\pgs4a-0.9.4\android.py", line 66, in <module>
main()
File "C:\Users\karuna\Desktop\Jython\Python\pgs4a-0.9.4\android.py", line 54, in main
build.build(iface, args.argument[0], args.argument[1:])
File "buildlib\build.py", line 301, in build
build_core(iface, directory, commands)
File "buildlib\build.py", line 221, in build_core
subprocess.call([plat.android, "update", "project", "-p", '.', '-t', 'android-8', '-n', versione
d_name])
File "C:\Python2.7 For Chintoo\lib\subprocess.py", line 493, in call
return Popen(*popenargs, **kwargs).wait()
File "C:\Python2.7 For Chintoo\lib\subprocess.py", line 679, in __init__
errread, errwrite)
File "C:\Python2.7 For Chintoo\lib\subprocess.py", line 893, in _execute_child
startupinfo)
WindowsError: [Error 2] The system cannot find the file specified
As obvious,
I am using Windows 7, and have:
Python 2.7.3
JDK
Android Emulator
Device drivers for my Sony Tipo.
Please help!
By the way,
I would prefer to get this running on my phone first. I am thinking of moving to the emulator later(after the tutorial is completed).
Is this question more suitable for https://android.stackexchange.com/?
I am not sure if this is still an issue for you, but I ran into the similar issue recently and managed to solve it so I will just leave a note here.
If anyone gets this kind of error, go to pgs4a folder and android-sdk folder. There, run SDK Manager.exe file. You will see a list of Tools and different android versions. Try to find the version that you are working on and install everything that is 'uninstalled'.
I managed to solve the above issue by installing everything under my current AND previous Android versions. Hope this will help anyone who ran into the same issue!
rename the folder android-sdk-windows to android-sdk

Ipython installation on 3.3 x64 errors

I don't have experience in downloading libraries, so any help is appreciated. I've got a fresh install of Python3.3 and am trying to get IPython for 64bit Windows 7. The IPython .exe installer ran fine and completed normally, but I can't access the program. I looked through their documentation, and tried the commands there, but
$ python setup.py install
returns invalid syntax, highlighting "setup". I thought the fix might be in the distribute library mentioned on the page, so I went to go try and get that first. However, using the script from distribute's install page revealed it's own errors, namely
Traceback (most recent call last):
File "C:\Python33\distribute_setup.py", line 541, in <module>
sys.exit(main())
File "C:\Python33\distribute_setup.py", line 537, in main
tarball = download_setuptools(download_base=options.download_base)
File "C:\Python33\distribute_setup.py", line 200, in download_setuptools
log.warn("Downloading %s", url)
File "C:\Python33\lib\distutils\log.py", line 47, in warn
self._log(WARN, msg, args)
File "C:\Python33\lib\distutils\log.py", line 30, in _log
if stream.errors == 'strict':
AttributeError: errors
I've been at it for a couple hours now, and I'm fresh out of ideas. What next?
It looks like you ran into Python bug 12967. You need to run distribute_setup.py outside of IDLE (i.e. in a command prompt).

Categories