Argument 1 has unexpected type 'str' - python

There are code for QGIS which used for parcel evaluation.
import processing
processing.run('qgis:postgisexecutesql', "parcell_GIS07", "select_parcel_eval('[%"cadnum" %]')")
qgis.utils.iface.mapCanvas().refresh()
When i try to use it on parcel in QGIS, it give off error window with this code:
An error occurred during execution of following code:
import processing
processing.run('qgis:postgisexecutesql', "parcell_GIS07", "select_parcel_eval('060130018')")
qgis.utils.iface.mapCanvas().refresh()
Traceback (most recent call last):
File "", line 2, in
File "C:/OSGEO4~1/apps/qgis/./python/plugins\processing\tools\general.py", line 106, in run
return Processing.runAlgorithm(algOrName, parameters, onFinish, feedback, context)
File "C:/OSGEO4~1/apps/qgis/./python/plugins\processing\core\Processing.py", line 133, in runAlgorithm
ok, msg = alg.checkParameterValues(parameters, context)
TypeError: QgsProcessingAlgorithm.checkParameterValues(): argument 1 has unexpected type 'str'

Related

Trying to create XML file and got "TypeError: SubElement() got multiple values for argument 'tag'"

While the following code snippet of a python program generates a nice xml file:
from proc import create_SRXML
create_SRXML.create_xml()
This following does not generate the xml file (the line "import pumoni.visu.renders as visua" is spoiling the job)
from proc import create_SRXML
import pumoni.visu.renders as visua
create_SRXML.create_xml()
and getting error log as follows:
Traceback (most recent call last):
File "processor/analyze_all.py", line 26, in <module>
create_SRXML.create_xml()
File "/datas/repo/work/pul/process/create_SRXML.py", line 13, in
create_xml
b1 = pulvii.SubElement(m1, "element",len="4",
name="FileMetaInformationGroupLength", tag="0002,0000", vm="1",
vr="UL")
TypeError: SubElement() got multiple values for argument 'tag'
May I know what the problem here is?

How to fix the error 'TypeError: can't pickle time objects'?

I am using the OpenOPC library to read data from an OPC Server, I am using 'Matrikon OPC Simulation Server', when I try to read the data it sends me the following error:
TypeError: can't pickle time objects
The code I use is the following, I run it from the python console.
CODE:
import OpenOPC
opc = OpenOPC.client()
opc.connect('Matrikon.OPC.Simulation')
opc.read('Random.Int4')
When I run the line opc.read ('Random.Int4'), that's when the error appears.
This is how the variable appears in my MatrikonOPC Explorer:
This is the complete error:
Traceback (most recent call last):
File "C:\Python27\Lib\multiprocessing\queues.py", line 264, in _feed
send(obj)
TypeError: can't pickle time objects
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "C:\Users\User\PycharmProjects\OPC2\venv\lib\site-packages\OpenOPC.py", line 625, in read
return list(results)
File "C:\Users\User\PycharmProjects\OPC2\venv\lib\site-packages\OpenOPC.py", line 543, in iread
raise TimeoutError('Callback: Timeout waiting for data')
TimeoutError: Callback: Timeout waiting for data
I solved this issue by adding sync=True when calling opc.read()
CODE:
import OpenOPC
opc = OpenOPC.client()
opc.connect('Matrikon.OPC.Simulation')
opc.read('Random.Int4', sync=True)
Reference: mkwiatkowski/openopc

GetItem(),ItemCount(),SubElements() functions not working in pywinauto

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'

Creating a track object with track_from_file method in pyechonest

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.

Error with divmod

Trying to run some code. Get this error when I do. I thought I had all the necessary dependencies installed, but still getting this error.
linux; GNU C++ version 4.8.1; Boost_105300; UHD_003.007.000-133-g6bd9fed2
Traceback (most recent call last):
File "/usr/local/bin/tpms_rx", line 274, in <module>
main()
File "/usr/local/bin/tpms_rx", line 265, in main
tb = top_block(source, args)
File "/usr/local/bin/tpms_rx", line 229, in __init__
self.source = source_rtlsdr(args.tuned_frequency, args.if_rate)
File "/usr/local/lib/python2.7/dist-packages/tpms/source.py", line 98, in __init__
rf_decimation, rf_decimation_remainder = divmod(rf_sampling_rate, if_sampling_rate)
TypeError: unsupported operand type(s) for divmod(): 'int' and 'NoneType'
When you run your program you need to pass a parameter -i/--if-rate or else the default is None which eventually gets passed, 2 layers later, to divmod.
See https://github.com/jboone/gr-tpms/blob/master/apps/tpms_rx and https://github.com/jboone/gr-tpms/blob/master/python/source.py additionally.

Categories