When i try to run the scan operation using the wifi library as mentioned in the documentation, i get the following error.
(lsbaws)Keshav:bin root# wifi scan
Traceback (most recent call last):
File "/Users/Keshav/Documents/Github/Webserver/webserver/lsbaws/bin/wifi", line 202, in <module>
args.func(args)
File "/Users/Keshav/Documents/Github/Webserver/webserver/lsbaws/bin/wifi", line 51, in scan_command
print_table([[cell.signal, cell.ssid, 'protected' if cell.encrypted else 'unprotected'] for cell in Cell.all(args.interface)])
File "/Users/Keshav/Documents/Github/Webserver/webserver/lsbaws/lib/python2.7/site-packages/wifi/scan.py", line 29, in all
stderr=subprocess.STDOUT)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 566, in check_output
process = Popen(stdout=PIPE, *popenargs, **kwargs)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 709, in __init__
errread, errwrite)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1326, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
I figured that this python wifi library does not work on mac.
An alternative to do wifi scanning is using the tool that comes in mac called airports.
To start using the tool -
$ cd /usr/sbin
$ sudo ln -s /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport
The airports -I flag is useful
Also just typing airports will open up the partly explicit manual page
Refrence link - Airports Example
Related
I want to run a python script periodically, so I use crontab. This is what my crontab -e looks like:
PATH=/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/usr/local/opt/python/libexec/bin
*/1 * * * * PYTHONPATH=/usr/local/lib/python/2.7/site-packages /usr/local/opt/python/libexec/bin/python /Users/username/Desktop/processes/test.py
The python version I am using is downloaded from home-brew.
As I've seen in many cases, I can run the test.py manually, but crontab -e does not seem to work. I might have included extra things, but I don't think these should affect the output.
The error I get through cat /var/mail/username is this one:
Traceback (most recent call last):
File "/Users/username/Desktop/processes/test.py”, line 34, in <module>
subprocess.call(['bash', commands_txt_shortened]) # Run the txt file to retrieve the images.
File "/usr/local/Cellar/python/2.7.14/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 168, in call
return Popen(*popenargs, **kwargs).wait()
File "/usr/local/Cellar/python/2.7.14/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 390, in __init__
errread, errwrite)
File "/usr/local/Cellar/python/2.7.14/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1025, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
Under MacOSX Sierra, and XQuartz 2.7.11, Python 2.7. I was able to install dryscrape and its required other python packages. I've tried quite a few methods to get some simple code working, but I can't seem to get it working. Here is the simple code:
#!/usr/bin/python
#coding: utf-8
import dryscrape
testurl = 'http://avi.im/stuff/js-or-no-js.html'
dryscrape.start_xvfb()
session = dryscrape.Session()
session.visit(testurl)
exit()
You can see it is a simple python script file. It fails on either the start_svfb() or the Session() line. I can post the errors and such, but can I start a discussion on simply what check list should I setup, run, and test to make sure the X11 environment is right? Do I run the script under OS X terminal or XQuartz? What am I missing? etc.?
Thanks in advance, Lucas.
here is the last traceback from python:
Traceback (most recent call last):
File "./fred.py", line 19, in
session = dryscrape.Session()
File "build/bdist.macosx-10.12-intel/egg/dryscrape/session.py", line 22, in __init__
File "build/bdist.macosx-10.12-intel/egg/dryscrape/driver/webkit.py", line 30, in __init__
File "/Library/Python/2.7/site-packages/webkit_server-1.0-py2.7.egg/webkit_server.py", line 230, in __init__
self.conn = connection or ServerConnection()
File "/Library/Python/2.7/site-packages/webkit_server-1.0-py2.7.egg/webkit_server.py", line 507, in __init__
self._sock = (server or get_default_server()).connect()
File "/Library/Python/2.7/site-packages/webkit_server-1.0-py2.7.egg/webkit_server.py", line 450, in get_default_server
_default_server = Server()
File "/Library/Python/2.7/site-packages/webkit_server-1.0-py2.7.egg/webkit_server.py", line 416, in __init__
stderr = subprocess.PIPE)
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'm currently building the source code for Adblock Plus for a school
project and I'm using the Autoinstall addon to easily deploy to my
browser, however the provided build tools in Python only seem to work
when I execute them in the Git Bash for some reason.
Here is the error message when I try to execute the command in the
Windows command line:
C:\Users\Evert\Documents\GitHub\adblockplus>python build.py autoinstall 8888
Traceback (most recent call last):
File "C:\Users\Evert\Documents\GitHub\adblockplus\ensure_dependencies.py", line 380, in <module>
resolve_deps(repo)
File "C:\Users\Evert\Documents\GitHub\adblockplus\ensure_dependencies.py", line 324, in resolve_deps
update_repo(target, vcs, rev)
File "C:\Users\Evert\Documents\GitHub\adblockplus\ensure_dependencies.py", line 272, in update_repo
resolved_revision = repo_types[type].get_revision_id(target, revision)
File "C:\Users\Evert\Documents\GitHub\adblockplus\ensure_dependencies.py", line 106, in get_revision_id
return subprocess.check_output(command, cwd=repo).strip()
File "C:\Python27\lib\subprocess.py", line 212, in check_output
process = Popen(stdout=PIPE, *popenargs, **kwargs)
File "C:\Python27\lib\subprocess.py", line 390, in __init__
errread, errwrite)
File "C:\Python27\lib\subprocess.py", line 640, in _execute_child
startupinfo)
WindowsError: [Error 2] The system cannot find the file specified
Command '['C:\\Python27\\python.exe', 'C:\\Users\\Evert\\Documents\\GitHub\\adblockplus\\ensure_dependencies.py', 'C:\\Users\\Evert\\Documents\\GitHub\\adblockplus']' returned non-zero exit status 1
Failed to ensure dependencies being up-to-date!
Traceback (most recent call last):
File "build.py", line 18, in <module>
buildtools.build.processArgs(BASE_DIR, sys.argv)
File "C:\Users\Evert\Documents\GitHub\adblockplus\buildtools\build.py", line 601, in processArgs
commands[command](baseDir, scriptName, opts, args, type)
File "C:\Users\Evert\Documents\GitHub\adblockplus\buildtools\build.py", line 55, in __call__
return self._handler(baseDir, scriptName, opts, args, type)
File "C:\Users\Evert\Documents\GitHub\adblockplus\buildtools\build.py", line 225, in runAutoInstall
packager.autoInstall(baseDir, type, host, port, multicompartment=multicompartment)
File "C:\Users\Evert\Documents\GitHub\adblockplus\buildtools\packagerGecko.py", line 334, in autoInstall
createBuild(baseDir, type=type, outFile=fileBuffer, multicompartment=multicompartment)
File "C:\Users\Evert\Documents\GitHub\adblockplus\buildtools\packagerGecko.py", line 294, in createBuild
version = getBuildVersion(baseDir, metadata, releaseBuild, buildNum)
File "C:\Users\Evert\Documents\GitHub\adblockplus\buildtools\packager.py", line 58, in getBuildVersion
buildNum = getBuildNum(baseDir)
File "C:\Users\Evert\Documents\GitHub\adblockplus\buildtools\packager.py", line 46, in getBuildNum
result = subprocess.check_output(['git', 'rev-list', 'HEAD'], cwd=baseDir)
File "C:\Python27\lib\subprocess.py", line 212, in check_output
process = Popen(stdout=PIPE, *popenargs, **kwargs)
File "C:\Python27\lib\subprocess.py", line 390, in __init__
errread, errwrite)
File "C:\Python27\lib\subprocess.py", line 640, in _execute_child
startupinfo)
WindowsError: [Error 2] The system cannot find the file specified
This isn't a huge problem for me since it does build, but I can't help but
wonder: what is the difference between these two environments that makes
this script work?
The issue appears to be that git.exe isn't in your Windows PATH, which it definitely is in Git Bash :) . You have two "not found" errors, both for git:
In ensure_dependencies.py, line 106, executing command. Per the source, the command is ['git', 'rev-parse', '--revs-only', rev + '^{commit}'].
In packager.py, line 46, executing ['git', 'rev-list', 'HEAD'].
Both of those are a missing git. To fix, before running python build.py, do
path %PATH%;c:\<wherever git.exe is located>
or add the location of git.exe to your system PATH using the Control Panel.
Edit If your Git installation is from GitHub, this answer gives details about adding Git to your PATH.
i installed python-nmap-0.1.4.tar.gz in pyhton27 in window. When i ran this http://codepad.org/vTu1Uw7I script, i got a few error. What those error mean?. Are those error happened because i used python-nmap-0.1.4.tar.gz in windows?.
Here is the error
Traceback (most recent call last):
File "C:/Python27/Lib/site-packages/nmap/run-nmap.py", line 3, in <module>
nm = nmap.PortScanner() # instantiate nmap.PortScanner object
File "C:/Python27/Lib/site-packages/nmap\nmap.py", line 118, in __init__
p = subprocess.Popen(['nmap', '-V'], bufsize=10000, stdout=subprocess.PIPE)
File "C:\Python27\lib\subprocess.py", line 711, in __init__
errread, errwrite)
File "C:\Python27\lib\subprocess.py", line 948, in _execute_child
startupinfo)
WindowsError: [Error 2] The system cannot find the file specified
Here is the subprocess.py script
http://codepad.org/SpbV8muR
Seems that python-nmap is meant to be run on Linux… but you can still try to make it work on Windows. The problem is that it is trying to call nmap but the binary is not found in PATH.
Add the directory with nmap executable to you PATH variable. Here is a HOWTO.
I am trying to run an existing python code, and having issues with it.
This program required npm program installed and which is installed at C:\Program Files\nodejs\npm in my computer. When I run the following code, as a part of the whole program, it throws errors.
def popen_results(args):
proc = subprocess.Popen(args, stdout=subprocess.PIPE)
return proc.communicate()[0]
def installed():
"""docstring for npm_installed"""
return popen_results(["which", "npm"]).strip()
This is the complete stack of the error thrown--
Checking for node and dependencies
Traceback (most recent call last):
File "deploy\deploy.py", line 344, in <module>
main()
File "deploy\deploy.py", line 287, in main
if not check_deps():
File "deploy\deploy.py", line 201, in check_deps
return npm.check_dependencies()
File "C:\Documents and Settings\Sunil\workspace\khan\src\deploy\npm.py", line
38, in check_dependencies
if not installed():
File "C:\Documents and Settings\Sunil\workspace\khan\src\deploy\npm.py", line
13, in installed
return popen_results(["which", "npm"]).strip()
File "C:\Documents and Settings\Sunil\workspace\khan\src\deploy\npm.py", line
8, in popen_results
proc = subprocess.Popen(args, stdout=subprocess.PIPE)
File "C:\python25\lib\subprocess.py", line 594, in __init__
errread, errwrite)
File "C:\python25\lib\subprocess.py", line 822, in _execute_child
startupinfo)
WindowsError: [Error 2] The system cannot find the file specified
I agree with martineau, it is unable to find which. The script may have been written with the assumption it was going to be run in a unix environment which would most likely have the "which" command available and in the default PATH. Since it looks like you're running this on Windows, I don't think it's going to work.
It looks like there is some alternatives to which on Windows though, discussed here: Is there an equivalent to which on Windows?