error of Exception has occurred: TypeError Lexer.make_tokens() missing 1 required positional argument: 'self' File "E:\zApp\zAxle\basic.py", line 115, in run tokens, error = Lexer.make_tokens() ^^^^^^^^^^^^^^^^^^^ File "E:\zApp\zAxle\shell.py", line 5,
#########################
# RUN
#########################
def run(text):
lexer = Lexer(text)
tokens, error = Lexer.make_tokens()
return tokens, error
looking online for it.
a working basick input and output the at came add subtrackt moltpliy and duvid
Related
I am using poetry and sys.argv.
I wrote the code in a OOP manner.
While I am running code from CLI, I am getting an error as shown below.
Traceback (most recent call last): File "<string>", line 1, in <module> TypeError: main() missing 1 required positional argument: 'self'
I am taking argument from CLI and passing it to my script as mentioned below.
list_of_ticker = sys.argv[1].split(',')
print(list_of_ticker)
foo = CalculateEtfsYahoo(list_of_ticker)
foo.main()
FYI,
The code is working, only after expected output I am getting above mentioned error.
Also, I have added the module.pakage:class.function in pyproject.toml as shown below.
[tool.poetry.scripts] findata = "investment.ParseFinData:CalculateEtfsYahoo.main"
When I am replacing above point 2 with "module.package:class"
[tool.poetry.scripts] findata = "investment.ParseFinData:CalculateEtfsYahoo"
And giving CLI command like this: poetry run findata.main <argument>
then, I am getting error as
Traceback (most recent call last): File "<string>", line 1, in <module> TypeError: CalculateEtfsYahoo() missing 1 required positional argument: 'list_of_ticker'
I do not know how to get rid of this error.
if everyrthing is working and you just want to get rid of the error you could use
import warnings
warnings.filterwarnings("ignore", category=TypeError) #I'm not sure this is the correct category but change it if needed.
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'
im using this code below but it doesnt work.. content of filepath available here peid.yara. full code here integrated_feature_extraction.py
def __init__(self,source,output,label):
self.source = source
self.output = output
self.type = label
#Need PEiD rules compile with yara
self.rules= yara.compile(filepath='/home/osboxes/honeymalware/scripts/peid.yara')
def check_packer(self,filepath):
result=[]
matches = self.rules.match(filepath)
if matches == []:
result.append([0,"NoPacker"])
else:
result.append([1,matches['main'][0]['rule']])
return result
def main():
source_path= raw_input("Enter the path of samples (ending with /) >> ")
output_file= raw_input("Give file name of output file. (.csv) >>")
label = raw_input("Enter type of sample( malware(1)|benign(0))>>")
when i run the program i get an error
Traceback (most recent call last):
File "integrated_features_extraction.py", line 375, in <module>
main()
File "integrated_features_extraction.py", line 372, in main
features.create_dataset()
File "integrated_features_extraction.py", line 356, in create_dataset
data = self.extract_all(filepath)
File "integrated_features_extraction.py", line 330, in extract_all
packer = self.check_packer(filepath)
File "integrated_features_extraction.py", line 239, in check_packer
result.append([1,matches['main'][0]['rule']])
TypeError: list indices must be integers, not str
i think problem occurred while executing result.append([1,matches['main'][0]['rule']]).what is wrong with the code above ??. what should i do ??
The output should be "no packer" or rulename in filepath.
The issue was with the change in match() method of Yara module. Earlier a dictionary was return so that was accessing using a key but now it returns a list and so there was a need to change the code.
I have written the script so I have updated the same on the GitHub project page.
else:
#result.append([1,matches['main'][0]['rule']])
result.append([1,matches[0]])
Thanks, everyone for finding and resolving the issue.
List can be accessed using indexes, example matches[0], matches[1], matches[2] .. etc., In your program, you accessed a list using a string 'main' and 'rule', matches['main'][0]['rule'] which raises an exception for TypeError.
Im trying to raise a custom exception message when I get an exception but I get the following error -
try:
query_start_time = time.time()
execute_sql_alchemy_query
except Exception as ex:
elapsed_time = (time.time() - query_start_time)/60
print(type(ex))
raise type(ex)("Query elapsed time(in mins) - {0}".format(elapsed_time))
Error:-
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/profiles/sources/impact/test.py", line 110, in _handle_future_exception
future.result()
File "/usr/local/lib/python3.7/concurrent/futures/_base.py", line 428, in result
return self.__get_result()
File "/usr/local/lib/python3.7/concurrent/futures/_base.py", line 384, in __get_result
raise self._exception
TypeError: __init__() missing 2 required positional arguments: 'params' and 'orig'
The exception being raised is probably a subclass of DBAPIError (https://docs.sqlalchemy.org/en/13/core/exceptions.html#sqlalchemy.exc.DBAPIError) which takes 3 positional/mandatory parameters in its constructor (statement, params and orig), by trying to raise it like this, you are only providing a “statement” but not the 2 other arguments.
You could probably manage to make it work by providing the .params and .orig from the initial exception but I’d discourage you to go that way because it’s error prone and a bit fragile (it will break if the exception is not a DBAPIError), instead I’d suggest to simply log the time separately from the error (using logging.warning)
I am using neo4jrestclient for Neo4j in python and locally it works perfectly. When I host it using webfaction it returns the following error:
TypeError at /add/
append() got an unexpected keyword argument 'data'
Django Version: 1.6.1
Exception Type: TypeError
Exception Value:
append() got an unexpected keyword argument 'data'
Exception Location: /home/kokos/lib/python2.7/neo4jrestclient/client.py in create, line 1036
I have no clue where the problem might be. Thanks in advance.
I have the same problem. See the minimal example below. It seems that query call messes up some internal state of library. I'll investigate further.
>>> gdb.node()
<Neo4j Node: http://localhost:7474/db/data/node/140>
>>> gdb.query("match (n) where 0 > 1 return n")
<neo4jrestclient.query.QuerySequence object at 0x00000000037A5C88>
>>> gdb.node()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Program Files\Python34\lib\site-packages\neo4jrestclient\client.py", line 1000, in __call__
return self.create(**kwargs)
File "C:\Program Files\Python34\lib\site-packages\neo4jrestclient\client.py", line 1036, in create
returns=NODE)
TypeError: append() got an unexpected keyword argument 'data'
It's because query stores corresponding transaction in global variable and this transaction is tried to be used during later call. However Transaction and QueryTransaction are different incompatible classes. See https://github.com/versae/neo4j-rest-client/issues/103.