Issue with whois and subprocess (Python 3.4; 64-bit Windows) - subprocess

So I'm just trying to get the suggested query (domain = whois.query("google.com")) working. But whenever I run it, I get the following traceback:
File "file.py", line x, in weight_sources
domain = whois.query("google.com")
File "C:\Users\User Name\Anaconda3\lib\site-packages\whois\__init__.py", line 50, in query
pd = do_parse(do_query(d, force, cache_file, slow_down, ignore_returncode), tld)
File "C:\Users\User Name\Anaconda3\lib\site-packages\whois\_1_query.py", line 44, in do_query
_do_whois_query(dl, ignore_returncode),
File "C:\Users\User Name\Anaconda3\lib\site-packages\whois\_1_query.py", line 58, in _do_whois_query
p = subprocess.Popen(['whois', '.'.join(dl)], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
File "C:\Users\User Name\Anaconda3\lib\subprocess.py", line 856, in __init__
restore_signals, start_new_session)
File "C:\Users\User Name\Anaconda3\lib\subprocess.py", line 1111, in _execute_child
startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified
I've seen some other questions/answers point to line 1111 in subprocess, but I think the issue might be in whois as I have used subprocess extensively without error on my device. Since the non-existent file seems to be related to the whois package, I don't think this question is related to this one, although the two could be related?
Essentially, is there any work around for this error or if I need to edit the whois package code, how would I go about that? I'm not exactly sure I even fully understand what "file" is missing...

The missing file is the whois executable, which is opened here:
subprocess.Popen(['whois', '.'.join(dl)]
The package description says whois is a wrapper for the Linux whois command. That means you must be running on Linux and have whois installed, but you are running Windows.
So I think you're out of luck with this package, maybe another one (such as python-whois) supports Windows.

Related

gsutil ConfigParser.ParsingError: File contains parsing errors

I'm working on a fastlane lane using pink-room's fastlane firebase test lab plugin which needs a gcloud service account to connect to firebase and upload files to a bucket.
The service account is needed because the script runs in a docker container which must not be worked by humans.
Gcloud command seem to work, because the test are launched as intended, but the gsutil command which is use to upload raw results is failing.
When this service account is loaded, gsutil commands stop working because they throw a ConfigParser.ParsingError "File contains parsing errors".
Here is what I get when trying to execute gsutil version -l in order to gather more informations:
Exit status of command 'gsutil version -l' was 1 instead of 0.
Traceback (most recent call last):
File "/usr/local/gcloud/google-cloud-sdk/platform/gsutil/gsutil", line 22, in <module>
gsutil.RunMain()
File "/usr/local/gcloud/google-cloud-sdk/platform/gsutil/gsutil.py", line 116, in RunMain
import gslib.__main__
File "/usr/local/gcloud/google-cloud-sdk/platform/gsutil/gslib/__main__.py", line 39, in <module>
import boto
File "/usr/local/gcloud/google-cloud-sdk/platform/gsutil/third_party/boto/boto/__init__.py", line 53, in <module>
config = Config()
File "/usr/local/gcloud/google-cloud-sdk/platform/gsutil/third_party/boto/boto/pyami/config.py", line 63, in __init__
self.read(BotoConfigLocations)
File "/usr/lib/python2.7/ConfigParser.py", line 305, in read
self._read(fp, filename)
File "/usr/lib/python2.7/ConfigParser.py", line 546, in _read
raise e
ConfigParser.ParsingError: File contains parsing errors: /builds/project-0/gcloud
/legacy_credentials/<service account mail>/.boto
[line 3]: '/legacy_credentials/<service account mail>/adc.json'
Here is my .boto file :
[Credentials]
gs_service_key_file = /builds/project-0/gcloud/legacy_credentials/<service account mail>/adc.json
Do someone knows where this error comes from, and how I can fix it ?
You say your boto file only has 2 lines, but I don't think that's the case, based on your error message :) I'm guessing either there's whitespace in there that you're not seeing (some unicode character that might not render correctly in your editor, perhaps?), or you didn't copy/paste the contents exactly as they appear in your file.
After finding a similar issue in this blog post, I noticed that the error you're seeing will print out the entire content of each problematic line that it found. It says it's printing line 3 (that shouldn't be possible if the boto file has only 2 lines), but doesn't show the gs_service_key_file = text. I'm guessing there's some sort of line break between gs_service_key_file = and /build/project-0/... in your boto file.

Unable to run pykalma example code that is reading MAT file with scipy

Below is the line of the code that pykalman example is using to load the matlab file robot.mat. However, it is throwing an error with message ValueError: Unknown mat file type, version 100, 110.
I am new to reading matlab files in Python. Can anyone help me understand exactly what version it is expecting and how to get around the issue?
data = io.loadmat(join(module_path, 'data', 'robot.mat'))
Traceback (most recent call last):
File "C:\ProgramData\Anaconda2\lib\site-
packages\IPython\core\interactiveshell.py", line 2881, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-4-0439d709929f>", line 1, in <module>
data = load_robot()
File "C:\ProgramData\Anaconda2\lib\site-packages\pykalman\datasets\base.py",
line 45, in load_robot
data = io.loadmat(join(module_path, 'data', 'robot.mat'))
File "C:\ProgramData\Anaconda2\lib\site-packages\scipy\io\matlab\mio.py",
line 135, in loadmat
MR = mat_reader_factory(file_name, appendmat, **kwargs)
File "C:\ProgramData\Anaconda2\lib\site-packages\scipy\io\matlab\mio.py",
line 59, in mat_reader_factory
mjv, mnv = get_matfile_version(byte_stream)
File "C:\ProgramData\Anaconda2\lib\site-
packages\scipy\io\matlab\miobase.py",
line 241, in get_matfile_version
raise ValueError('Unknown mat file type, version %s, %s' % ret)
ValueError: Unknown mat file type, version 100, 110
I'm guessing here (and adding one more idea to hpaulj's good overview):
First i checked the file manually and opening in an editor reads as:
MATLAB 5.0 MAT-file, Platform: MACI64, Created on: Tue Jun 26 00:59:04 2012
...
Therefore there should be no problem in regards to scipy (if the mat-file is actually following this "header").
Now it seems there are some open issues with that project with the most relevant beeing:
Unable to load robot.mat #59
(Don't be surprised too much with the different eror-values as i would expect possibly indeterministic stuff like that when bad IO is beeing done)
and: pykalman/datasets/ not copied when pykalman is installed with pip #66
So it seems this dataset does not come with pip-install automatically, which looks like your problem and should be easily handled (manually obtaining the data!). It is also compatible with hpaulj's wondering about that strange error (one could argue if there is no better error-handling possible).

Enthought Canopy - "IOError: [Errno 10038]" when install or update packages in Package Manager

I have installed Canopy 1.7.4.3348 (64 bit). My OS is Windows 10 (64 bit). I have the most updated Canopy and Windows 10.
When I tried to update and install any packages in Package Manager, the "Status" would turn out to be "Error", and I got the message:
IOError: [Errno 10038] An operation was attempted on something that is not a socket.
I looked up the Error code on microsoft.com (https://msdn.microsoft.com/en-us/library/windows/desktop/ms740668(v=vs.85).aspx) and found Microsoft's definition of socket error 10038:
WSAENOTSOCK 10038
Socket operation on nonsocket.
An operation was attempted on something that is not a socket.
Either the socket handle parameter did not reference a valid socket,
or for select, a member of an fd_set was not valid.
I think this error from Canopy may only exist in Windows but not in other OS like Linux. Could anyone please kindly help with this issue? Really appreciate it!!
The detailed messages are as below:
Warming up...
Traceback (most recent call last):
File "build\bdist.win-amd64\egg\canopy_dashboard\packman\package_action_worker.py", line 54, in run
File "build\bdist.win-amd64\egg\canopy_dashboard\packman\package_action.py", line 193, in execute
File "build\bdist.win-amd64\egg\canopy_dashboard\packman\packman.py", line 346, in <lambda>
File "build\bdist.win-amd64\egg\canopy_dashboard\packman\packman.py", line 893, in _install
File "build\bdist.win-amd64\egg\canopy_platform\cpython_packages_manager.py", line 98, in install_package
File "build\bdist.win-amd64\egg\canopy_platform\enpkg_api.py", line 102, in install_package
File "build\bdist.win-amd64\egg\canopy_platform\enpkg_api.py", line 177, in _execute_in_subprocess
File "build\bdist.win-amd64\egg\canopy_platform\enpkg_api.py", line 212, in _propagate_progress_events
IOError: [Errno 10038] An operation was attempted on something that is not a socket
Please file a bug report from the Canopy help menu for Enthought tech support records (and please refer to this SO question in your report).
I don't know what causes this rare error, but it should disappear in Canopy 2.0, which uses a different package manager backend, based on the Enthought Deployment Manager (EDM).
Meanwhile, you can avoid the error by using the command-line package installer, enpkg, from a Canopy Command Prompt. Please see this Knowledge Base article for details: https://support.enthought.com/entries/22415022-Using-enpkg-to-update-Canopy-EPD-packages.

Error when creating virtualenv folder

I am working through the book Test Driven Devlopement, and am currently having a problem when I try to create a virtualenv folder using:
virtualenv --python=python3 ../virtualenv
I keep on getting this output:
Traceback (most recent call last):
File "C:\Python33\lib\runpy.py", line 160, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "C:\Python33\lib\runpy.py", line 73, in _run_code
exec(code, run_globals)
File "C:\Python33\Scripts\virtualenv.exe\__main__.py", line 9, in <module>
File "C:\Python33\lib\site-packages\virtualenv.py", line 774, in main
interpreter = resolve_interpreter(options.python)
File "C:\Python33\lib\site-packages\virtualenv.py", line 1575, in resolve_interpreter
python_versions = get_installed_pythons()
File "C:\Python33\lib\site-packages\virtualenv.py", line 93, in get_installed_pythons
path = winreg.QueryValue(python_core, "%s\\InstallPath" % ver)
FileNotFoundError: [WinError 2] The system cannot find the file specified
You are on windows: ../virutalenv is for unix
On unix, you are telling virtualenv to create a virtualenv directory in the directory up one level (previous) also windows uses backslash instead of slash.
Try to find a tutorial that is windows oriented, or if you can get your hand on a unix/linux machine, or maybe install cygwin.

How do I use environment variables in Supervisord's [supervisord] config section?

I use environment variables in Supervisord's program section, and they work just fine:
[program:some_prog]
command=%(ENV_env_var_name)s/...
I can't figure out though how to do the same in the [supervisord] section.
I tried using the same syntax with and without the ENV_ prefix, but getting the following error:
Traceback (most recent call last):
File "/usr/local/bin/supervisord", line 9, in <module>
load_entry_point('supervisor==3.0a12', 'console_scripts', 'supervisord')()
File "/usr/local/lib/python2.7/dist-packages/supervisor-3.0a12-py2.7.egg/supervisor/supervisord.py", line 356, in main
options.realize(args, doc=__doc__)
File "/usr/local/lib/python2.7/dist-packages/supervisor-3.0a12-py2.7.egg/supervisor/options.py", line 419, in realize
Options.realize(self, *arg, **kw)
File "/usr/local/lib/python2.7/dist-packages/supervisor-3.0a12-py2.7.egg/supervisor/options.py", line 284, in realize
self.process_config_file()
File "/usr/local/lib/python2.7/dist-packages/supervisor-3.0a12-py2.7.egg/supervisor/options.py", line 478, in process_config_file
Options.process_config_file(self, do_usage=do_usage)
File "/usr/local/lib/python2.7/dist-packages/supervisor-3.0a12-py2.7.egg/supervisor/options.py", line 292, in process_config_file
self.read_config(self.configfile)
File "/usr/local/lib/python2.7/dist-packages/supervisor-3.0a12-py2.7.egg/supervisor/options.py", line 527, in read_config
section.directory = existing_directory(directory)
File "/usr/local/lib/python2.7/dist-packages/supervisor-3.0a12-py2.7.egg/supervisor/datatypes.py", line 336, in existing_directory
nv = v % {'here':here}
KeyError: 'var_name'
Is there a way to achieve that?
Supervisor only supports expansions with environment variables in a limited number of locations, each of which is documented in the configuration documentation.
Unfortunately, the [supervisord] directory option is not one of those; it only supports the %(here) variable, nothing else.
You could file a feature request for this in the supervisord issue tracker if this an important issue for you.
In my projects, we generally use zc.buildout to make deployment and development environment setup predictable and repeatable, and generate the supervisor configuration from a template. There is a specialized buildout recipe to make this task easier.