I'm trying to automate the process of switch between networks in "Cisco AnyConnect", but my code always is terminated with an 'EOF error'.
I've tried a search in API doc for some help and used different expressions like: "Network", "Network:" or "Network.*".
from pexpect import popen_spawn
import pexpect
vpnui = pexpect.popen_spawn.PopenSpawn(r'C:\Program Files (x86)\Cisco\Cisco AnyConnect Secure Mobility Client\vpnui.exe', maxread=2000)
vpnui.expect('Network:')
vpnui.sendline('SomeNetwork')
The error:
Traceback (most recent call last): File
"C:\Users\myUser\AppData\Local\Programs\Python\Python36\lib\site-packages\pexpect\expect.py",
line 111, in expect_loop
incoming = spawn.read_nonblocking(spawn.maxread, timeout) File "C:\Users\myUser\AppData\Local\Programs\Python\Python36\lib\site-packages\pexpect\popen_spawn.py",
line 75, in read_nonblocking
raise EOF('End Of File (EOF).') pexpect.exceptions.EOF: End Of File (EOF).
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File
"C:\Users\myUser\eclipse-workspace\teste\switchGuestWifi.py", line 15,
in
vpnui.expect('Network:') File "C:\Users\myUser\AppData\Local\Programs\Python\Python36\lib\site-packages\pexpect\spawnbase.py",
line 341, in expect
timeout, searchwindowsize, async_) File "C:\Users\myUser\AppData\Local\Programs\Python\Python36\lib\site-packages\pexpect\spawnbase.py",
line 369, in expect_list
return exp.expect_loop(timeout) File "C:\Users\myUser\AppData\Local\Programs\Python\Python36\lib\site-packages\pexpect\expect.py",
line 117, in expect_loop
return self.eof(e) File "C:\Users\myUser\AppData\Local\Programs\Python\Python36\lib\site-packages\pexpect\expect.py",
line 63, in eof
raise EOF(msg) pexpect.exceptions.EOF: End Of File (EOF).
searcher: searcher_re:
0: re.compile(b'Network:')
Related
I was about to start using mongodb as my database project. I'm always stuck when want to pushing some data to it. I use mongodb atlas. This code below always resulting errors. I've following and learning about mongodb from online (like youtube, w3, etc)
import pymongo
from pymongo import MongoClient
url = "mongodb+srv://<username>:<password>#cluster0.oecqh.mongodb.net/test?retryWrites=true&w=majority"
cluster = MongoClient(url)
db = cluster["discord"]
collection = db["discord"]
push = {"name": "test", "value": "test"}
try:
collection.insert_one(push)
except Exception as e:
print(e)
The errors
Exception ignored in: <function Client.__del__ at 0x00000213C5D84940>
Traceback (most recent call last):
File "C:\Users\chris\AppData\Local\Programs\Python\Python39\lib\site-packages\httpx\_client.py", line 1139, in __del__
self.close()
File "C:\Users\chris\AppData\Local\Programs\Python\Python39\lib\site-packages\httpx\_client.py", line 1111, in close
self._transport.close()
AttributeError: 'Client' object has no attribute '_transport'
Exception in thread Thread-1:
Traceback (most recent call last):
File "C:\Users\chris\AppData\Local\Programs\Python\Python39\lib\threading.py", line 973, in _bootstrap_inner
self.run()
File "C:\Users\chris\AppData\Local\Programs\Python\Python39\lib\site-packages\dns\win32util.py", line 48, in run
self.info.domain = _config_domain(interface.DNSDomain)
File "C:\Users\chris\AppData\Local\Programs\Python\Python39\lib\site-packages\dns\win32util.py", line 26, in _config_domain
if domain.startswith('.'):
AttributeError: 'NoneType' object has no attribute 'startswith'
Traceback (most recent call last):
File "C:\Users\chris\AppData\Local\Programs\Python\Python39\lib\site-packages\pymongo\srv_resolver.py", line 89, in _resolve_uri
results = _resolve(
File "C:\Users\chris\AppData\Local\Programs\Python\Python39\lib\site-packages\pymongo\srv_resolver.py", line 43, in _resolve
return resolver.resolve(*args, **kwargs)
File "C:\Users\chris\AppData\Local\Programs\Python\Python39\lib\site-packages\dns\resolver.py", line 1193, in resolve
return get_default_resolver().resolve(qname, rdtype, rdclass, tcp, source,
File "C:\Users\chris\AppData\Local\Programs\Python\Python39\lib\site-packages\dns\resolver.py", line 1063, in resolve
(nameserver, port, tcp, backoff) = resolution.next_nameserver()
File "C:\Users\chris\AppData\Local\Programs\Python\Python39\lib\site-packages\dns\resolver.py", line 646, in next_nameserver
raise NoNameservers(request=self.request, errors=self.errors)
dns.resolver.NoNameservers: All nameservers failed to answer the query _mongodb._tcp.cluster0.oecqh.mongodb.net. IN SRV:
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\Users\chris\OneDrive\Documents\Programming\Python\tempCodeRunnerFile.py", line 5, in <module>
cluster = MongoClient(url)
File "C:\Users\chris\AppData\Local\Programs\Python\Python39\lib\site-packages\pymongo\mongo_client.py", line 704, in __init__
res = uri_parser.parse_uri(
File "C:\Users\chris\AppData\Local\Programs\Python\Python39\lib\site-packages\pymongo\uri_parser.py", line 542, in parse_uri
nodes = dns_resolver.get_hosts()
File "C:\Users\chris\AppData\Local\Programs\Python\Python39\lib\site-packages\pymongo\srv_resolver.py", line 121, in get_hosts
_, nodes = self._get_srv_response_and_hosts(True)
File "C:\Users\chris\AppData\Local\Programs\Python\Python39\lib\site-packages\pymongo\srv_resolver.py", line 101, in _get_srv_response_and_hosts
results = self._resolve_uri(encapsulate_errors)
File "C:\Users\chris\AppData\Local\Programs\Python\Python39\lib\site-packages\pymongo\srv_resolver.py", line 97, in _resolve_uri
raise ConfigurationError(str(exc))
pymongo.errors.ConfigurationError: All nameservers failed to answer the query _mongodb._tcp.cluster0.oecqh.mongodb.net. IN SRV:
This question already has answers here:
Python speech recognition error converting mp3 file
(2 answers)
Closed 2 years ago.
import speech_recognition as sr
print(sr.__version__)
r = sr.Recognizer()
file_audio = sr.AudioFile('damn1.mp3')
with file_audio as source:
audio_text = r.record(source)
print(type(audio_text))
print(r.recognize_google(audio_text))
I have a problem running this program. The output I get is as following:
Traceback (most recent call last):
File "C:\Users\kubar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\speech_recognition\__init__.py", line 203, in __enter__
self.audio_reader = wave.open(self.filename_or_fileobject, "rb")
File "C:\Users\kubar\AppData\Local\Programs\Python\Python38-32\lib\wave.py", line 510, in open
return Wave_read(f)
File "C:\Users\kubar\AppData\Local\Programs\Python\Python38-32\lib\wave.py", line 164, in __init__
self.initfp(f)
File "C:\Users\kubar\AppData\Local\Programs\Python\Python38-32\lib\wave.py", line 131, in initfp
raise Error('file does not start with RIFF id')
wave.Error: file does not start with RIFF id
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\kubar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\speech_recognition\__init__.py", line 208, in __enter__
self.audio_reader = aifc.open(self.filename_or_fileobject, "rb")
File "C:\Users\kubar\AppData\Local\Programs\Python\Python38-32\lib\aifc.py", line 917, in open
return Aifc_read(f)
File "C:\Users\kubar\AppData\Local\Programs\Python\Python38-32\lib\aifc.py", line 352, in __init__
self.initfp(file_object)
File "C:\Users\kubar\AppData\Local\Programs\Python\Python38-32\lib\aifc.py", line 316, in initfp
raise Error('file does not start with FORM id')
aifc.Error: file does not start with FORM id
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\kubar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\speech_recognition\__init__.py", line 234, in __enter__
self.audio_reader = aifc.open(aiff_file, "rb")
File "C:\Users\kubar\AppData\Local\Programs\Python\Python38-32\lib\aifc.py", line 917, in open
return Aifc_read(f)
File "C:\Users\kubar\AppData\Local\Programs\Python\Python38-32\lib\aifc.py", line 358, in __init__
self.initfp(f)
File "C:\Users\kubar\AppData\Local\Programs\Python\Python38-32\lib\aifc.py", line 314, in initfp
chunk = Chunk(file)
File "C:\Users\kubar\AppData\Local\Programs\Python\Python38-32\lib\chunk.py", line 63, in __init__
raise EOFError
EOFError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\kubar\OneDrive\Pulpit\men.py", line 7, in <module>
with file_audio as source:
File "C:\Users\kubar\AppData\Local\Programs\Python\Python38-32\lib\site-packages\speech_recognition\__init__.py", line 236, in __enter__
raise ValueError("Audio file could not be read as PCM WAV, AIFF/AIFF-C, or Native FLAC; check if file is corrupted or in another format")
ValueError: Audio file could not be read as PCM WAV, AIFF/AIFF-C, or Native FLAC; check if file is corrupted or in another format
MP3 is a compressed format. Never use it when you manipulate audio since the large majority of tools handling audio does it on non compressed audio streams. So, even when such tool accepts your file, it probably starts by converting it, which consumes time and spaces. Moreover, MP3 is never used by professionals working on audio (musician, engineers, etc.) : avoid using it with audio materials having some importance for your work (even for archiving because the compression is not reversible), always prefer using non compressed formats as WAV or AIF instead (here the library seems to expect AIF).
I am trying to read raw data using pyvisa which communicates with MDO3014 oscilloscope.
The code I have tried is as follows:-
import pyvisa
rm = pyvisa.ResourceManager()
usb = rm.list_resources()[0]
my_instrument = rm.open_resource(usb)
print(my_instrument.query('*IDN?'))
my_instrument.timeout = 25000
my_instrument.write('SAVE:IMAGe:FILEF PNG')
my_instrument.write('HARDCOPY:START')
raw_data = my_instrument.read_raw()
I am getting timeout error, the traceback of error logs is as follows:-
('USB0::0x0699::0x0408::C031378::INSTR', 'ASRL1::INSTR', 'ASRL3::INSTR')
TEKTRONIX,MDO3014,C031378,CF:91.1CT FV:v1.30
Traceback (most recent call last):
File "waveform_capture.py", line 14, in <module>
raw_data = my_instrument.read_raw()
File "C:\Users\venugopal.venkatesh\.virtualenvs\python_oscilloscope-zAKD9iXY\lib\site-packages\pyvisa\resources\messagebased.py", line 405, in read_raw
return bytes(self._read_raw(size))
File "C:\Users\venugopal.venkatesh\.virtualenvs\python_oscilloscope-zAKD9iXY\lib\site-packages\pyvisa\resources\messagebased.py", line 442, in _read_raw
chunk, status = self.visalib.read(self.session, size)
File "C:\Users\venugopal.venkatesh\.virtualenvs\python_oscilloscope-zAKD9iXY\lib\site-packages\pyvisa\ctwrapper\functions.py",
line 2337, in read
ret = library.viRead(session, buffer, count, byref(return_count))
File "C:\Users\venugopal.venkatesh\.virtualenvs\python_oscilloscope-zAKD9iXY\lib\site-packages\pyvisa\ctwrapper\highlevel.py",
line 222, in _return_handler
return self.handle_return_value(session, ret_value) # type: ignore
File "C:\Users\venugopal.venkatesh\.virtualenvs\python_oscilloscope-zAKD9iXY\lib\site-packages\pyvisa\highlevel.py", line 251,
in handle_return_value
raise errors.VisaIOError(rv)
pyvisa.errors.VisaIOError: VI_ERROR_TMO (-1073807339): Timeout expired before operation completed.
I am trying to create connection to Hive hosted in HDInsight cluster through my python script and getting below error-
Traceback (most recent call last):
File "ClassLoader.java", line 357, in java.lang.ClassLoader.loadClass
File "Launcher.java", line 349, in sun.misc.Launcher$AppClassLoader.loadClass
File "ClassLoader.java", line 424, in java.lang.ClassLoader.loadClass
File "URLClassLoader.java", line 382, in java.net.URLClassLoader.findClass
java.lang.ClassNotFoundException: java.lang.ClassNotFoundException: org.apache.thrift.transport.TTransportException
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "org.jpype.JPypeContext.java", line 330, in org.jpype.JPypeContext.callMethod
File "Method.java", line 498, in java.lang.reflect.Method.invoke
File "DelegatingMethodAccessorImpl.java", line 43, in sun.reflect.DelegatingMethodAccessorImpl.invoke
File "NativeMethodAccessorImpl.java", line 62, in sun.reflect.NativeMethodAccessorImpl.invoke
File "NativeMethodAccessorImpl.java", line -2, in sun.reflect.NativeMethodAccessorImpl.invoke0
File "DriverManager.java", line 247, in java.sql.DriverManager.getConnection
File "DriverManager.java", line 664, in java.sql.DriverManager.getConnection
File "HiveDriver.java", line 105, in org.apache.hive.jdbc.HiveDriver.connect
Exception: Java Exception
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "s.py", line 5, in <module>
"/root/jdbc/hive-jdbc-1.2.1000.2.6.5.3009-43.jar")
File "/usr/local/lib64/python3.6/site-packages/jaydebeapi/__init__.py", line 412, in connect
jconn = _jdbc_connect(jclassname, url, driver_args, jars, libs)
File "/usr/local/lib64/python3.6/site-packages/jaydebeapi/__init__.py", line 230, in _jdbc_connect_jpype
return jpype.java.sql.DriverManager.getConnection(url, *dargs)
java.lang.NoClassDefFoundError: java.lang.NoClassDefFoundError: org/apache/thrift/transport/TTransportException
My Script is -
import jaydebeapi
conn = jaydebeapi.connect("org.apache.hive.jdbc.HiveDriver",
"jdbc:hive2://10.20.30.40:10001/default;transportMode=http;ssl=false;httpPath=/hive2",
["username", "password"],
"/root/jdbc/hive-jdbc-1.2.1000.2.6.5.3009-43.jar")
I have exported CLASSPATH wil all jar files.
The error is java.lang.ClassNotFoundException: java.lang.ClassNotFoundException which specifies that the execution is not able to find the jar /root/jdbc/hive-jdbc-1.2.1000.2.6.5.3009-43.jar.I believe it's only placed in a host from where you are executing the code. I would suggest placing the jar file in the same directory structure in all the nodes in the cluster and have a check on permissions so that the user executing the job has access to that path.
I am using pycharm on Python 2.7. I have installed PyNomo. I am trying to run this small example from the official site. Code is available on the link, I have simply copy pasted it. I get the following error:
Aligning with tag A
Traceback (most recent call last):
File "/home/darshil/Desktop/Caltech Summer Internship/Radiation Ononcology Data/DB/rad3/pynomo_temp.py", line 71, in <module>
Nomographer(main_params)
File "/usr/local/lib/python2.7/dist-packages/pynomo/nomographer.py", line 203, in __init__
wrapper.draw_nomogram(c,params['post_func'])
File "/usr/local/lib/python2.7/dist-packages/pynomo/nomo_wrapper.py", line 213, in draw_nomogram
block.draw(canvas)
File "/usr/local/lib/python2.7/dist-packages/pynomo/nomo_wrapper.py", line 445, in draw
atom.draw(canvas)
File "/usr/local/lib/python2.7/dist-packages/pynomo/nomo_wrapper.py", line 2503, in draw
axis_appear=p,base_start=base_start,base_stop=base_stop)
File "/usr/local/lib/python2.7/dist-packages/pynomo/nomo_axis.py", line 123, in __init__
self.draw_axis(canvas)
File "/usr/local/lib/python2.7/dist-packages/pynomo/nomo_axis.py", line 1067, in draw_axis
c.text(x,y,ttext,attr+[text_color])
File "/usr/local/lib/python2.7/dist-packages/pyx/canvas.py", line 324, in text
return self.insert(self.texrunner.text(x, y, atext, *args, **kwargs))
File "/usr/local/lib/python2.7/dist-packages/pyx/text.py", line 1194, in text
self.execute(expr, self.defaulttexmessagesdefaultrun + self.texmessagesdefaultrun + texmessages)
File "/usr/local/lib/python2.7/dist-packages/pyx/text.py", line 951, in execute
self.defaulttexmessagesstart + self.texmessagesstart)
File "/usr/local/lib/python2.7/dist-packages/pyx/text.py", line 1005, in execute
self.texinput.write(self.expr)
IOError: [Errno 32] Broken pipe
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
File "/usr/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
func(*targs, **kargs)
File "/usr/local/lib/python2.7/dist-packages/pyx/text.py", line 748, in _cleantmp
texrunner.texinput.write("\n\\end\n")
IOError: [Errno 32] Broken pipe
Error in sys.exitfunc:
Traceback (most recent call last):
File "/usr/lib/python2.7/atexit.py", line 24, in _run_exitfuncs
func(*targs, **kargs)
File "/usr/local/lib/python2.7/dist-packages/pyx/text.py", line 748, in _cleantmp
texrunner.texinput.write("\n\\end\n")
IOError: [Errno 32] Broken pipe
Process finished with exit code 1
The error is in the final line of the code:
Nomographer(main_params)
I have looked at other questions with "broken pipe error": here,here, and here. But none of them are helpful to me.
Any indication on how to solve would be very helpful.
PyNomo uses a TeX installation to typeset text. Maybe this is missing resulting in a broken pipe. You need to be able to run a file hello.tex with the content Hello, world!\bye on a command line tex hello.tex. It should result in a file hello.dvi. If not you need to install a TeX distribution like TeXLive.