I'm trying to automate tasks for teamcenter using pywinauto python module.But I was not able to work properly with TreeViews. When ever I'm trying to use GetItem(),SubElements(),Item() and many other function under _treeview_element giving error.Please look into below errors.
I'm using python 2.7 and i also have pywin32 module installed
for i in range(tr.ItemCount()):
print tr.GetItem(i)
Traceback (most recent call last):
File "<pyshell#61>", line 2, in <module>
print tr.GetItem(i) File "C:\Users\patibj\Desktop\pywinauto-
master\pywinauto\controls\common_controls.py", line 1010, in GetItem
if isinstance(path[0], int):
TypeError: 'int' object has no attribute '__getitem__'
This is when i'm trying to use GetChild()
a[0] is <pywinauto.controls.common_controls._treeview_element object at 0x02EC11B0> a[0].GetChild((1))
Traceback (most recent call last):
File "<pyshell#49>", line 1, in <module>
a[0].GetChild((1))
File "C:\Users\patibj\Desktop\pywinauto- master\pywinauto\controls\common_controls.py", line 840, in GetChild
return self.Children()[index]
File "C:\Users\patibj\Desktop\pywinauto-master\pywinauto\controls\common_controls.py", line 739, in Children
if self.Item().cChildren not in (0, 1):
File "C:\Users\patibj\Desktop\pywinauto-master\pywinauto\controls\common_controls.py", line 539, in Item
return self._readitem()[0]
File "C:\Users\patibj\Desktop\pywinauto-master\pywinauto\controls\common_controls.py", line 904, in _readitem
raise ctypes.WinError() WindowsError: [Error 0] The operation completed successfully.
Please help me out .Thanks in advance.
TreeViewWrapper.GetItem() method gets path argument which should be the string starting with back-slash \\ symbol. Example:
app.Dialog.TreeView.GetItem('\\1st_level_item_name\\2ndlevelitem').Click()
For access by index use a list of integers:
app.Dialog.TreeView.GetItem([1, 0])
GetChild() works with explorer.exe TreeView:
>>> tree.GetItem([1]).GetChild(2).Text()
u'Computer'
Related
Whenever I try to use this looping functionality, it gives me an error that has lines that are further than the end of my code. I am fairly new to python and coding in general, but I think this is part of a repository I downloaded. The error code looks like this
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/player.py", line 603, in run
self._do_run()
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/player.py", line 590, in _do_run
data = self.source.read()
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/player.py", line 543, in read
ret = self.original.read()
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/player.py", line 228, in read
ret = self._stdout.read(OpusEncoder.FRAME_SIZE)
AttributeError: 'NoneType' object has no attribute 'read'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/player.py", line 616, in _call_after
self.after(error)
File "main.py", line 242, in play_next_song
raise VoiceError(str(error))
VoiceError: 'NoneType' object has no attribute 'read'
My Entire code block is here. I am trying to host this discord bot in repl.it, if that has anything to do with it.
Any help would be appreciated, Thanks!
The relevant part of the stacktrace is actually the last one:
File "main.py", line 242, in play_next_song
raise VoiceError(str(error))
VoiceError: 'NoneType' object has no attribute 'read'
You cannot use the same FFmpegPCMAudio object twice. You have the create a new one.
I am trying to make a program that translates whatever you say in Swedish and PyAutoGUI Typewrites it. But when I run the code, I just get the same error.
trans=Translator()
translating_text=input('Enter text to translate into S w e d i s h:')
t=trans.translate(translating_text,src='en',dest='sv')
time.sleep(5)
translated=t
pyautogui.typewrite(translated)
pyautogui.press('enter')
The error:
Traceback (most recent call last):
File "C:\Users\admin\Documents\Python Projects\CrendlePy.py", line 56, in <module>
ahm_swedish()
File "C:\Users\admin\Documents\Python Projects\CrendlePy.py", line 54, in ahm_swedish
pyautogui.typewrite(translated)
File "C:\Users\admin\AppData\Local\Programs\Python\Python39\lib\site-
packages\pyautogui\__init__.py", line 586, in wrapper
returnVal = wrappedFunction(*args, **kwargs)
File "C:\Users\admin\AppData\Local\Programs\Python\Python39\lib\site-
packages\pyautogui\__init__.py", line 1665, in typewrite
for c in message:
TypeError: 'Translated' object is not iterable
Can someone pls help me with this?
Error speaks for its self, pyautogui.typewrite() is expecting iterable, for example, string, but you are passing Translated object.
You have to explore the way to get text out of your Translated object and only then pass it to pyautogui.
I am trying to run this python program https://github.com/shuque/pydig.
When I try to run the pydig.py file with python pydig www.example.com I get an error message saying:
Traceback (most recent call last):
File "pydig", line 8, in <module>
sys.exit(main(sys.argv))
File "C:\Users\User\desktop\pydig-master\pydiglib\main.py", line 20, in main qname, qtype, qclass = parse_args(args[1:])
File "C:\Users\User\desktop\pydig-master\pydiglib\options.py", line 206, in parse_args options["server"] = get_default_server()
File "C:\Users\User\desktop\pydig-master\pydiglib\util.py", line 156, in get_default_server s = get_windows_default_dns()
File "C:\Users\User\desktop\pydig-master\pydiglib\windows.py", line 7, in get_windows_default_dns match_obj = re_ipv4.search(output)
TypeError: cannot use a string pattern on a bytes-like object
Can someone tell me what's the problem? I am using Python 3.7.
Ok, i kinda solved it by returning a fixed server IP.
But i couldn't get it to work by decoding the byte to stream to a string.
So I'm trying to get scapy to work on my windows computer. After a lot of work I finally was able to load the library without any errors. However when I call the function sniff(count=1) I get an error. It seems that a variable called "device" is getting the value None. Here is the error :
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python34\lib\site-packages\scapy\arch\windows\__init__.py", line 445, in sniff
s = L2socket(type=ETH_P_ALL, *arg, **karg)
File "C:\Python34\lib\site-packages\scapy\arch\pcapdnet.py", line 266, in __init__
self.ins = open_pcap(iface, 1600, self.promisc, 100)
File "C:\Python34\lib\site-packages\scapy\arch\windows\__init__.py", line 223, in <lambda>
pcapdnet.open_pcap = lambda iface,*args,**kargs: _orig_open_pcap(pcap_name(iface),*args,**kargs)
File "C:\Python34\lib\site-packages\scapy\arch\pcapdnet.py", line 251, in <lambda>
open_pcap = lambda *args,**kargs: _PcapWrapper_pypcap(*args,**kargs)
File "C:\Python34\lib\site-packages\scapy\arch\pcapdnet.py", line 215, in __init__
self.iface = create_string_buffer(device.encode('ascii'))
AttributeError: 'NoneType' object has no attribute 'encode'
Thanks In Advance For Any Help :)
After downloading the new development version and tinkering around with the timeouts of some of the powershell commands I fixed it! Guess it was just a bug with the old version. Scapy doesn't have the best Windows support.
I am new to python. I am trying to use track_from_file method in pyechonest to create a track object. This is the code I wrote:
from pyechonest import config
from pyechonest.track import track_from_file
config.ECHO_NEST_API_KEY = "KRZG4XOVUQRKI45DP"
f = open("ShayneWard-NoPromises.mp3")
t = track_from_file(f, 'mp3')
But this is not working. I got an EchoNestIOError. This is the full error Traceback that i got.
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "build/bdist.linux-x86_64/egg/pyechonest/track.py", line 243, in track_from_file
File "build/bdist.linux-x86_64/egg/pyechonest/track.py", line 331, in track_from_md5
File "build/bdist.linux-x86_64/egg/pyechonest/track.py", line 209, in _profile
File "build/bdist.linux-x86_64/egg/pyechonest/util.py", line 257, in callm pyechonest.util.
EchoNestIOError: Echo Nest Unknown Error
Can anyone tell me what have I done wrong?
I finally figured it out. It seems that the upload does not take place through the proxy server of my university network which uses NAT.