"on_server_role_update" TypeError Missing Argument - typeerror

So... I dont know what to say, im going to be quick obviously
CODE:
#bot.event
async def on_server_role_update(role, before, after):
print("[" + (colored("{}".format(role.server), 'blue')) + "] " + (colored("Role Updated: {0} >> {1}".format(before, after), 'yellow')))
ERROR:
TypeError: on_server_role_update() missing 1 positional argument: 'after'
You see? I have the argument but it shows an error!

on_server_role_update should have exactly two arguments: a Role before and a Role after. Why did you think there was a third role argument?
#bot.event
async def on_server_role_update(before, after):
server_blue = colored(str(before.server), 'blue')
msg = "Role Updated: {0} >> {1}".format(before, after)
color_msg = colored(msg, 'yellow')
print("[{}] {}".format(server_blue, color_msg))

Related

Pytest Selenium elem.send_keys() causing TypeError: object of type 'NoneType' has no len()

I am trying to send data to a login textbox but when I use 'send_keys' I get an error..
def wait_for_element(selenium, selenium_locator, search_pattern, wait_seconds=10):
elem = None
wait = WebDriverWait(selenium, wait_seconds)
try:
if (selenium_locator.upper() == 'ID'):
elem = wait.until(
EC.visibility_of_element_located((By.ID, search_pattern))
)
except TimeoutException:
pass
return elem
userid=os.environ.get('userid')
wait_for_element(selenium, "ID", 'username')
assert elem is not None
elem.click()
time.sleep(3)
elem.send_keys(userid)
tests\util.py:123: in HTML5_login
elem.send_keys(userid)
..\selenium\webdriver\remote\webelement.py:478: in send_keys
{'text': "".join(keys_to_typing(value)),
value = (None,)
def keys_to_typing(value):
"""Processes the values that will be typed in the element."""
typing = []
for val in value:
if isinstance(val, Keys):
typing.append(val)
elif isinstance(val, int):
val = str(val)
for i in range(len(val)):
typing.append(val[i])
else:
for i in range(len(val)):
for i in range(len(val)):
E TypeError: object of type 'NoneType' has no len()
I have no clue why it is saying the element is of "NoneType" when I have it pass an assertion as well as click the element. I can even see it clicking the element when I run the test!
This error message...
elem.send_keys(userid) ..\selenium\webdriver\remote\webelement.py:478: in send_keys {'text': "".join(keys_to_typing(value)), value = (None,)
TypeError: object of type 'NoneType' has no len()
...implies that send_keys() method encountered an error when sending the contents of the variable userid.
Though you have tried to use the variable userid, I don't see the variable userid being declared anywhere within your code block. Hence you see the error:
TypeError: object of type 'NoneType' has no len()
Solution
Initialize the userid variable as:
userid = "Austin"
Now, execute your test.

Struggling with flask-socketio rooms

I have a project where I need to build a chat platform using flask-socketio. Everything works until I try to add rooms, I get the following error:
application.py", line 92, in on_join
send({"msg", username + " has joined the " + room + " room."}, room=room) TypeError: unsupported operand type(s) for +: 'NoneType'
and 'str'
I'm not really sure where to look
#socketio.on('join')
def on_join(data):
"""User joins a room"""
username = data["username"]
room = data["room"]
join_room(room)
# Broadcast that new user has joined
send({"msg", username + " has joined the " + room + " room."}, room=room)
function joinRoom(room) {
// Join room
socket.emit('join', {'username': localStorage.getItem('displayname'), 'room': room});
// Clear message area
document.querySelector('#messages').innerHTML = '';
// Autofocus on text box
document.querySelector("#display-messages").focus();
}
Should output "username has joined the 'roomname' room.", clear the message list as the channel changes, and allow you to speak in the new channel.

dlm package - Error in optim(parm, logLik, method = method, ...) : L-BFGS-B needs finite values of 'fn'

require(dlm)
start.vals = c(0,0,0)
names(start.vals) = c("lns2_obs", "lns2_alpha", "lns2_beta")
buildTVP <- function(parm, x.mat){
parm <- exp(parm)
return( dlmModReg(X=x.mat, dV=parm[1], dW=c(parm[2], parm[3])) )
}
TVP.mle = dlmMLE(y=k[,1], parm=start.vals, x.mat=k[,2], build=buildTVP, hessian=T)
in this code, k[,1] and k[,2] are 2 stocks prices. on TVP.mle line I got
Error in optim(parm, logLik, method = method, ...) : L-BFGS-B needs finite values of 'fn' " error.
k file link: https://drive.google.com/open?id=1scLaKRpSdmp-1T9qTp_5cEcBFnWKDAus
I could not find my mistake. Could you help me please?

debug in openerp6.1

I have added the following code in sale.py but I am unable to see output of print in
server.log. I wish to fill a one2many field by returned list of this function
I am using openerp6.1 under windows xp
my code is
def model_id_change(self,cr,uid,ids,model_id,context=None):
list1=[]
if context is None:
context = {}
print "Hi"
print str(model_id)
if not model_id:
raise osv.except_osv(_('No Model Selected !'),_('You have to select Model.'))
querystr = 'SELECT microswitch FROM product_model WHERE id = ' + model_id
print querystr
try:
cr.execute(querystr)
s=cr.fetchone()
print s
list1=[]
print list1
for t in s.split(','):
if t:
list1.append(t)
except:
exceptionType, exceptionValue, exceptionTraceback = sys.exc_info()
return(list1)
The print statement prints to standard output. If you want to get something in the server log, use the logging module.
import logging
logger = logging.getLogger(__name__)
logger.info('my message, with a substituted variable %s', s)

grails internationalization (i18n)

i work on grails project
def result = "customer"
//(this value is according to returned method parameter,
//it may be customer, company,... & so on)
def messages = "${message(code: 'default.result.${result}', default:'${result}')}"
i need to send a variable inside message code as i mention above
problem: this code appears as
default.result.${result}
that there is no code in message.properties refer to these code
there is default.result.customer ....$ so on
Question: how can i send variable inside message Code?
Try omitting the double quotes (GString) and it should work like the following:
def xxx = "bar"
def m = message(code: "foo.${xxx}", args: ['hello world'])
Results in following message-code
foo.bar
Try:
def messages = message(code: 'default.result.' + result, default: result)
If you want to pass in some values, e.g. a string, you can define your message like this:
default.result.success = Action {0} was successfull.
And resolve your code like this:
def m = message(code: 'default.result.' + result, args: ['delete User'])