awaiting for aiofiles.os.remove() returns TypeError: object NoneType can't be used in 'await' expression - python-aiofiles

I'm trying to remove a file from a local directory asynchronously; however, I get the following error:
object NoneType can't be used in 'await' expression ()
I'm using ver aiofiles 0.5.0 and Python 3.6.5
my code is as straightforward as such:
async def delete_local_file(file_to_del):
await aiof.os.remove(file_to_del)
print("deleted: "+file_to_del)
await delete_local_file(localfile)

accidentally I used the wrong reference during import. simply use:
import aiofiles.os

Related

Jmeter: BeanshellAssertion Error: Method Not Found In Class

I simply want to read response from jdbc sampler and use it in an http request.
I created a BeanShellAssertion Script under a jdbc request and wrote just the below code, nothing else.
if(vars.getObjects("jdbcresult1").size!=0)
{
String jdbcresult1=vars.getObjects("jdbcresult1").get(0).get("jdbctrackingnumber1")+"";
vars.put("trackingnumber1",jdbcresult1);
log.info("TrackingNumber1 is: "+trackingnumber1);
}
Error:
2020-08-13 23:32:47,030 ERROR o.a.j.u.BeanShellInterpreter: Error
invoking bsh method: eval Sourced file: inline evaluation of: ``import
java.lang.Object; if(vars.getObjects("jdbcresult1").size!=0) {
String . . . '' : Error in method invocation: Method getObjects(
java.lang.String ) not found in
class'org.apache.jmeter.threads.JMeterVariables'
2020-08-13 23:32:47,030 WARN o.a.j.a.BeanShellAssertion: Error in
BeanShellAssertion
Question1: How do you decide what should you use to write a code to read jdbcresponse value:
a. beanshellassertion
b. beanshellpostprocessor
c. beanshelllistener
Question2: Solution to the original problem, to resolve the error ?
The problem is that:
vars.getObjects(...)
does not exist.
It should be :
vars.getObject(...)
See:
https://jmeter.apache.org/api/org/apache/jmeter/threads/JMeterVariables.html
Also it’s better to use JSR223 Assertion:
https://jmeter.apache.org/usermanual/component_reference.html#JSR223_Assertion

Building lambda function to connect to Postgresql getting :Unable to import module 'lambda_function': No module named 'psycopg2'

I am testing my api gateway to call lambda function.
i was successful in the test.
i was then trying to make a connection to postgresql through the same lambda
import json
import psycopg2
db_host = "hostname"
db_port = 5432
db_name ="db name"
db_user ="user"
db_pass ="password"
def connect():
conn = None
try :
conn = psycopg2.connect("dbname={} user={} host={} password={}".format(db_name,db_user,db_host,db_pass))
except :
print("connetion error")
return conn
print("Loading function")
def lambda_handler(event, context):
# paring query from the string
name = event['queryStringParameters']['name']
action = event['queryStringParameters']['action']
print('name = '+name )
print('action = '+action)
# body of the response object
transactionResponse = {}
transactionResponse['name'] = name
transactionResponse['action'] = action
transactionResponse['message'] = 'Lambda called from api_gateway'
# construting Http response
responseObject = {}
responseObject['statusCode'] = 200
responseObject['headers'] {}
responseObject['headers']['Content-Type'] = 'application/json'
responseObject['body'] = json.dumps(transactionResponse)
# return the response object
return responseObject
when i tried to trigger it through the API endpoint i got
Unable to import module 'lambda_function': No module named 'psycopg2'
then i went ahead and build my lambda function by downloading the required package and then uploaded a zip file .
when i try to call try the same to trigger the lambda i am getting
Runtime.ImportModuleError: Unable to import module 'lambda_function': No module named 'lambda_function'
don't know what lamda_function is .
Could any one suggest me out of this slump ?
or
provide me a way to connect to RDS through lambda from API gateway trigger
This is my build Package
the issue is no longer there.
Get the psycopg2 build library from https://github.com/jkehler/awslambda-psycopg2 was built for python 3.6 and make sure you change the name to psycopg2 while uploading your code to AWS lambda, select Python Runtime environment as 3.6, and it should work.
Can you check the lambda_handler settings and ensure they are correctly set to represent your function:
You should check the lambda handler name from the console. This is likely to be caused because the handler name is referring to lambda_function.foobar but the filename of the Lambda within the zip would be not be named lambda_function.py.
Ensure the name is in the format filename.function_name.
In this example if the file was named lambda_function then the handler value should be lambda_function.lambda_handler.
The directory structure does not currently include the psycopg2 module so this will still not be able to be loaded.
To solve this the following solutions are applicable:
Add the dependency via pip install, then zip up again deploy
Add a Lambda layer with this dependency already installed

Call to undefined function auth()

Call to undefined function App\Http\Controllers\auth()
If I follow through the step by step instructions provided jwt-auth
I have copy pasted this AuthConstroller
$token = auth()->attempt($credentials);
Error Message: Call to undefined function App\Http\Controllers\auth()
Framework version 5.7.7
Package version 1.0.0-rc.2
PHP version 7.2.9
My AuthController
I think it's more like
Auth::attempt($credentials)

How can I generate a Parsing Error in BitBake on intent?

I use Anonymous Python Functions in BitBake recipes to set variables during parsing.
Now I wonder if I can check if a specific variable is set or not. If not, then I want to generate a BitBake Error, which stops the build process.
Pseudo code, that I want to create:
python __anonymous () {
if d.getVar('MY_VARIABLE', True) == "":
<BITBAKE ERROR with custom message "MY_VARIABLE not found">
}
You can call bb.fatal("MY_VARIABLE not set") which will print that error and abort the build by throwing an exception.
Beware that d.getVar() returns None when the variable is unset. You only get the empty string if that's your default value.
Outputs are possible on different loglevels and with python as well as shell script code
For usage in python there are:
bb.fatal
bb.error
bb.warn
bb.note
bb.plain
bb.debug
For usage in shell script there are:
bbfatal
bberror
bbwarn
bbnote
bbplain
bbdebug
for example if you want to throw an error in your recipe's do_install_append function:
bbfatal "something went terribly wrong!"

Arduino HTTPClient not working

I have an Arduino with an Ethernet shield.
I have the httpclient library, and I am trying to run the PachubeClient example.
When I compile, it gives me many errors:
PachubeClient.cpp:25:25: error: Credentials.h: No such file or directory
PachubeClient.cpp: In function 'void setup()':
PachubeClient:47: error: 'ssid' was not declared in this scope
PachubeClient:47: error: 'passphrase' was not declared in this scope
PachubeClient:55: error: a function-definition is not allowed here before '{' token
PachubeClient:95: error: expected `}' at end of input
Why?
I haven't played around with the Arduino development environment at all but that error message means you're either missing the Credentials.h file or the compiler doesn't know where to find it. Verify that the file exists and then check your compiler settings to make sure that you're passing it the path to the header files.