Getting error when running music bot, discord rewrite - discord.py

I get an error in one of my cogs. I believe it is talking about the attributes guild not being in discord.client:
File "/Users/me/Desktop/Personal Coding/Music-bot-forward/bot.py", line 27, in <module>
bot.add_cog(Player(client))
File "/Users/me/Desktop/Personal Coding/Music-bot-forward/music.py", line 16, in __init__
self.setup()
File "/Users/me/Desktop/Personal Coding/Music-bot-forward/music.py", line 19, in setup
for guild in self.bot.guilds:
AttributeError: module 'discord.client' has no attribute 'guilds'
The tutorial:https://youtube.com/watch?v=46ZHJcNnPJ8&feature=share
The code:https://pastebin.com/abgvsD29
I am new to the Discord.py library and do not really understand the docs either

The reason being was in my code,await ctx.voice.channel.connect() You would need to replace that with await ctx.author.voice.channel.connect().

Related

h2o hit_ratio_table AttributeError

I'm following a tutorial from https://github.com/h2oai/h2o-tutorials/blob/master/tutorials/gbm-randomforest/GBM_RandomForest_Example.py
I have been following the tutorial until I reached the line with hit_ratio_table. when I executed
"rf_v1.hit_ratio_table(valid=True)", I encounter the error below.
>>> rf_v1.hit_ratio_table(valid=True)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/h2oUser/sparkling-water-2.3.0/py/build/dist/h2o_pysparkling_2.3-2.3.0.zip/h2o/utils/backward_compatibility.py", line 74, in __getattr__
File "/home/h2oUser/sparkling-water-2.3.0/py/build/dist/h2o_pysparkling_2.3-2.3.0.zip/h2o/utils/backward_compatibility.py", line 49, in __getattribute__
AttributeError: type object 'H2ORandomForestEstimator' has no attribute 'hit_ratio_table'
I tried to search if hit_ratio_table is being deprecated or not, but I can't find any links. Does anyone know if this function has been changed?
The attribute is still there, it looks like the tutorial is missing a line of code right after the file import, which means the model is being considered as a regression problem instead of a classification problem. So if you add the following line after you import the covtype dataset:
covtype_df[54] = covtype_df[54].asfactor()
which converts the target to a factor, it should work.
If you want to play around with the hit_ratio_table() you can look at this code snippet in the H2O-3 user guide.

Discord.py rewrite 'Context' object has no attribute 'send'

Last month I hosted a Discord.py (async version) bot on heroku and it worked perfect, this month I updated my bot from async to rewrite and it doesn't really work.
On my requirements.txt file I have put the git+https://github.com/Rapptz/discord.py#rewrite#egg=discord.py[voice] but it doesn't work.
I always get this error:
2019-01-25T08:30:23.592293+00:00 app[worker.1]: Traceback (most recent call last):
2019-01-25T08:30:23.592356+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.6/site-packages/discord/ext/commands/bot.py", line 846, in process_commands
2019-01-25T08:30:23.592358+00:00 app[worker.1]: yield from command.invoke(ctx)
2019-01-25T08:30:23.592363+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.6/site-packages/discord/ext/commands/core.py", line 374, in invoke
2019-01-25T08:30:23.592365+00:00 app[worker.1]: yield from injected(*ctx.args, **ctx.kwargs)
2019-01-25T08:30:23.592395+00:00 app[worker.1]: File "/app/.heroku/python/lib/python3.6/site-packages/discord/ext/commands/core.py", line 54, in wrapped
2019-01-25T08:30:23.592397+00:00 app[worker.1]: raise CommandInvokeError(e) from e
2019-01-25T08:30:23.592435+00:00 app[worker.1]: discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'Context' object has no attribute 'send'
Script:
print("Loading Script")
print("Loading Libs")
import discord
import random
from discord.ext import commands
print("Loading Bot")
bot = commands.Bot(command_prefix='!')
#bot.event
async def on_ready():
print("Online!")
#bot.command()
async def rps(ctx):
rpsa = ["Rock", "Paper", "Scissors"]
rpsr = random.choice(rpsa)
await ctx.send(rpsr)
bot.run(Token)
Are you sure you have the right version installed? Just having it in your requirements file doesn't guarantee that you are using the right one. Check what you have installed with pip freeze and then uninstall if necessary the old async version.
That type of error only occurs when you have the async version of discord.py installed and are using rewrite features
Double check what your requirements.txt file is called (you've named it requirement.txt in the question) and check that it doesn't still contain discord==0.0.2 or
discord.py==0.16.12

using rabbitmqadmin to access CloudAMQP / Heroku

I'm starting out to learn about AMQP and RabbitMQ.
To get myself going I have used a CLI tool, rabbitmqadmin, to successfully publish data to a RabbitMQ development install I have created upon my Mac OS X box. So far so good, I can publish messages, and watch them dequeue...
However when I come to try the exact same functionality upon the Heroku / CloudAMQP instance the rabbitmqadmin client seems to fall over.
This is the call:
rabbitmqadmin --host lemur.cloudamqp.com --vhost app4444444_heroku.com --user app4444444_heroku.com --password <withheld> publish routing_key=test payload="hello"
...and this is the output:
Traceback (most recent call last):
File "/usr/local/bin/rabbitmqadmin", line 828, in <module>
main()
File "/usr/local/bin/rabbitmqadmin", line 325, in main
method()
File "/usr/local/bin/rabbitmqadmin", line 428, in invoke_get
result = self.post(uri, json.dumps(upload))
File "/usr/local/bin/rabbitmqadmin", line 354, in post
return self.http("POST", path, body)
File "/usr/local/bin/rabbitmqadmin", line 377, in http
resp = conn.getresponse()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 1013, in getresponse
response.begin()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 402, in begin
version, status, reason = self._read_status()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 366, in _read_status
raise BadStatusLine(line)
httplib.BadStatusLine: ''
Any thoughts or ideas gratefully received!
Add --ssl to the command line. CloudAMQP's web ui is https only.

Ubuntu 10.04 - Python multiprocessing - 'module' object has no attribute 'local' error

The following code is from the python 2.6 manual.
from multiprocessing import Process
import os
def info(title):
print(title)
print('module name:', 'me')
print('parent process:', os.getppid())
print('process id:', os.getpid())
def f(name):
info('function f')
print('hello', name)
if __name__ == '__main__':
info('main line')
p = Process(target=f, args=('bob',))
p.start()
p.join()
This creates the following stack traces:
Traceback (most recent call last):
File "threading.py", line 1, in <module>
from multiprocessing import Process
File "/usr/lib/python2.6/multiprocessing/__init__.py", line 64, in <module>
from multiprocessing.util import SUBDEBUG, SUBWARNING
File "/usr/lib/python2.6/multiprocessing/util.py", line 287, in <module>
class ForkAwareLocal(threading.local):
AttributeError: 'module' object has no attribute 'local'
Exception AttributeError: '_shutdown' in <module 'threading' from '/home/v0idnull/tmp/pythreads/threading.pyc'> ignored
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
File "/usr/lib/python2.6/atexit.py", line 24, in _run_exitfuncs
func(*targs, **kargs)
File "/usr/lib/python2.6/multiprocessing/util.py", line 258, in _exit_function
info('process shutting down')
TypeError: 'NoneType' object is not callable
Error in sys.exitfunc:
Traceback (most recent call last):
File "/usr/lib/python2.6/atexit.py", line 24, in _run_exitfuncs
func(*targs, **kargs)
File "/usr/lib/python2.6/multiprocessing/util.py", line 258, in _exit_function
info('process shutting down')
TypeError: 'NoneType' object is not callable
I'm completely clueless as to WHY this is happening, and google has given me very little to work with.
that code runs fine on my machine:
Ubuntu 10.10, Python 2.6.6 64-bit.
but your error is actually because you have a file named 'threading.py' that you are running this code from (see the stack-trace details). this is causing a namespace mismatch, since the multiprocessing module needs the 'real' threading module. try renaming your file to something other than 'threading.py' and running it again.
also... the example you posted is not from the Python 2.6 docs... it is from the Python 3.x docs. make sure you are reading the docs for the version that matches what you are running.

Django on IIS with Multiple Sites: How To Make ISAPI.py Cooperate

Python 2.6.2 / Django 1.0.2 on Win 2003 Standard IIS 6.
IIs is running two django sites with the following directory structure:
root/http/WEBSITE1
root/http/WEBSITE2
Both sites have their own application pools; each site has it's own pyISAPIe.dll instance.
WEBSITE1 is accessible (serving test django page). However, the browser produces the following for WEBSITE2:
Internal Server Error
An error occurred processing this request.
Request handler failed
Traceback (most recent call last):
File "D:\Python26\lib\site-packages\Http\Isapi.py", line 67, in Request
return RunWSGI(Handler, Base=Base)
File "D:\Python26\lib\site-packages\Http\WSGI.py", line 155, in RunWSGI
Result = Application(Environ, StartResponse)
File "D:\Python26\lib\site-packages\django\core\handlers\wsgi.py", line 241, in call
response = self.get_response(request)
File "D:\Python26\lib\site-packages\django\core\handlers\base.py", line 122, in get_response
return self.handle_uncaught_exception(request, resolver, sys.exc_info())
File "D:\Python26\lib\site-packages\django\core\handlers\base.py", line 166, in handle_uncaught_exception
return callback(request, **param_dict)
File "D:\Python26\lib\site-packages\django\views\defaults.py", line 23, in server_error
t = loader.get_template(template_name) # You need to create a 500.html template.
File "D:\Python26\lib\site-packages\django\template\loader.py", line 81, in get_template
source, origin = find_template_source(template_name)
File "D:\Python26\lib\site-packages\django\template\loader.py", line 74, in find_template_source
raise TemplateDoesNotExist, name
django.template.TemplateDoesNotExist: 500.html
It seems to me that "Isapi.py" located in root/pytho26/Lib/site-packages/Http has everything to do with this because of the "os.environ["DJANGO_SETTINGS_MODULE"] = "WEBSITE1.settings"
How can I modify this file or position it so that both sites run independently.
For anyone interested, the solution lies here
http://groups.google.com/group/pyisapie/browse_thread/thread/b67e861c85e1b26a
Follow option #3 to the letter and you will be able to run multiple IIS sites.

Resources