Ubuntu, Skype and Python - python

I am using Skype4Py and create a skype bot.
I wanted to install the bot on a linux enviroment (Ubuntu 12.04 as I recall right)
And I installed skype and the bot + dependicies.
Now whenever I ask for message.Chat.Type, it gives me a command timeout..
Any solution?
error:
Exception in thread Skype4Py MessageStatus event scheduler:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 551, in __bootstrap_inner
self.run()
File "/usr/local/lib/python2.7/dist-packages/Skype4Py/utils.py", line 225, in run
handler(*self.args, **self.kwargs)
File "functions/messageProcessor.py", line 161, in processMessages
if allowed(message, "url_parse"):
File "functions/messageProcessor.py", line 62, in allowed
chatType = message.Chat.Type
File "/usr/local/lib/python2.7/dist-packages/Skype4Py/chat.py", line 405, in _GetType
return str(self._Property('TYPE'))
File "/usr/local/lib/python2.7/dist-packages/Skype4Py/chat.py", line 33, in _Property
return self._Owner._Property('CHAT', self.Name, PropName, Value, Cache)
File "/usr/local/lib/python2.7/dist-packages/Skype4Py/skype.py", line 296, in _Property
value = self._DoCommand('GET %s' % jarg, jarg)
File "/usr/local/lib/python2.7/dist-packages/Skype4Py/skype.py", line 276, in _DoCommand
self.SendCommand(command)
File "/usr/local/lib/python2.7/dist-packages/Skype4Py/skype.py", line 778, in SendCommand
self._Api.send_command(Command)
File "/usr/local/lib/python2.7/dist-packages/Skype4Py/api/posix_x11.py", line 445, in send_command
raise SkypeAPIError('Skype command timeout')
SkypeAPIError: Skype command timeout

Related

Miniconda: cannot launch spyder

I have always been able to launch spyder without any issues. But today I started running into the following error messages. I don't understand why is it complaining no workingdir? How do I resolve this, as I cannot even launch spyder ?
Traceback (most recent call last):
File "C:\Users\xxx\AppData\Local\miniconda\envs\py3_10\Scripts\spyder-script.py", line 10, in <module>
sys.exit(main())
File "C:\Users\xxx\AppData\Local\miniconda\envs\py3_10\lib\site-packages\spyder\app\start.py", line 253, in main
mainwindow.main(options, args)
File "C:\Users\xxx\AppData\Local\miniconda\envs\py3_10\lib\site-packages\spyder\app\mainwindow.py", line 1956, in main
mainwindow = create_window(MainWindow, app, splash, options, args)
File "C:\Users\xxx\AppData\Local\miniconda\envs\py3_10\lib\site-packages\spyder\app\utils.py", line 289, in create_window
main.setup()
File "C:\Users\xxx\AppData\Local\miniconda\envs\py3_10\lib\site-packages\spyder\app\mainwindow.py", line 771, in setup
PLUGIN_REGISTRY.register_plugin(self, PluginClass,
File "C:\Users\xxx\AppData\Local\miniconda\envs\py3_10\lib\site-packages\spyder\api\plugin_registration\registry.py", line 342, in register_plugin
instance = self._instantiate_spyder5_plugin(
File "C:\Users\xxx\AppData\Local\miniconda\envs\py3_10\lib\site-packages\spyder\api\plugin_registration\registry.py", line 193, in _instantiate_spyder5_plugin
plugin_instance.initialize()
File "C:\Users\xxx\AppData\Local\miniconda\envs\py3_10\lib\site-packages\spyder\api\plugins\new_api.py", line 669, in initialize
self.on_initialize()
File "C:\Users\xxx\AppData\Local\miniconda\envs\py3_10\lib\site-packages\spyder\plugins\workingdirectory\plugin.py", line 82, in on_initialize
container.set_history(
File "C:\Users\xxx\AppData\Local\miniconda\envs\py3_10\lib\site-packages\spyder\plugins\workingdirectory\container.py", line 323, in set_history
workdir = self._get_init_workdir()
File "C:\Users\xxx\AppData\Local\miniconda\envs\py3_10\lib\site-packages\spyder\plugins\workingdirectory\container.py", line 183, in _get_init_workdir
workdir = self.get_conf('startup/fixed_directory')
File "C:\Users\xxx\AppData\Local\miniconda\envs\py3_10\lib\site-packages\spyder\api\config\mixins.py", line 76, in get_conf
return CONF.get(section, option, default)
File "C:\Users\xxx\AppData\Local\miniconda\envs\py3_10\lib\site-packages\spyder\config\manager.py", line 499, in get
value = config.get(section=section, option=option, default=default)
File "C:\Users\xxx\AppData\Local\miniconda\envs\py3_10\lib\site-packages\spyder\config\user.py", line 980, in get
return config.get(section=section, option=option, default=default)
File "C:\Users\xxx\AppData\Local\miniconda\envs\py3_10\lib\site-packages\spyder\config\user.py", line 511, in get
raise cp.NoSectionError(section)
configparser.NoSectionError: No section: 'workingdir'

Why do I get this discord.py error on my VPS but not my home PC?

I'm making a discord bot in python, and when I run it on my windows 10 pc it runs fine, but if I run it on my ubuntu VPS it gives me a massive error.
Windows 10 python version: 3.9
Ubuntu version: 3.5 (I don't think 3.9 is on ubuntu, I cant find it anywhere)
Error:
File "bot.py", line 1923, in <module>
client.run(config.token)
File "/home/ubuntu/.local/lib/python3.5/site-packages/discord/client.py", line 519, in run
self.loop.run_until_complete(self.start(*args, **kwargs))
File "/usr/lib/python3.5/asyncio/base_events.py", line 387, in run_until_complete
return future.result()
File "/usr/lib/python3.5/asyncio/futures.py", line 274, in result
raise self._exception
File "/usr/lib/python3.5/asyncio/tasks.py", line 239, in _step
result = coro.send(None)
File "/home/ubuntu/.local/lib/python3.5/site-packages/discord/client.py", line 491, in start
yield from self.connect()
File "/home/ubuntu/.local/lib/python3.5/site-packages/discord/client.py", line 448, in connect
yield from self.ws.poll_event()
File "/home/ubuntu/.local/lib/python3.5/site-packages/discord/gateway.py", line 431, in poll_event
yield from self.received_message(msg)
File "/home/ubuntu/.local/lib/python3.5/site-packages/discord/gateway.py", line 390, in received_message
func(data)
File "/home/ubuntu/.local/lib/python3.5/site-packages/discord/state.py", line 509, in parse_guild_create
server = self._get_create_server(data)
File "/home/ubuntu/.local/lib/python3.5/site-packages/discord/state.py", line 483, in _get_create_server
server._from_data(data)
File "/home/ubuntu/.local/lib/python3.5/site-packages/discord/server.py", line 218, in _from_data
self._sync(guild)
File "/home/ubuntu/.local/lib/python3.5/site-packages/discord/server.py", line 250, in _sync
channel = Channel(server=self, **c)
File "/home/ubuntu/.local/lib/python3.5/site-packages/discord/channel.py", line 89, in __init__
self._update(**kwargs)
File "/home/ubuntu/.local/lib/python3.5/site-packages/discord/channel.py", line 116, in _update
self._permission_overwrites.append(Overwrites(**overridden))
TypeError: __new__() got an unexpected keyword argument 'deny_new'
Task was destroyed but it is pending!
task: <Task pending coro=<ConnectionState._delay_ready() running at /home/ubuntu/.local/lib/python3.5/site-packages/discord/state.py:173> wait_for=<Future pending cb=[Task._wakeup()]>>```

discord.py bot crashes randomly

I'm using discord.py v0.16.12, and I occasionally get this traceback that crashes the bot. The token is present and valid even though the traceback leads you to believe otherwise.
Traceback (most recent call last):
File "main.py", line 94, in <module>
bot.run(auth.get('discord', 'TOKEN'))
File "/home/ubuntu/.local/lib/python3.6/site-packages/discord/client.py", line 519, in run
self.loop.run_until_complete(self.start(*args, **kwargs))
File "/usr/lib/python3.6/asyncio/base_events.py", line 484, in run_until_complete
return future.result()
File "/home/ubuntu/.local/lib/python3.6/site-packages/discord/client.py", line 491, in start
yield from self.connect()
File "/home/ubuntu/.local/lib/python3.6/site-packages/discord/client.py", line 448, in connect
yield from self.ws.poll_event()
File "/home/ubuntu/.local/lib/python3.6/site-packages/discord/gateway.py", line 431, in poll_event
yield from self.received_message(msg)
File "/home/ubuntu/.local/lib/python3.6/site-packages/discord/gateway.py", line 390, in received_message
func(data)
File "/home/ubuntu/.local/lib/python3.6/site-packages/discord/state.py", line 256, in parse_message_update
message.embeds = data['embeds']
KeyError: 'embeds'
This was an issue that was fixed with v1.2.0 of discord.py.
v0.16.12 is an outdated version of discord.py that isn't supported anymore.
You should look into migrating to v1.

When added ipdb at flask app it raises RuntimeError: There is no current event loop in thread

Okay now I'm working on simple flask app and it is working but while working I needed ipdb at certain api, after I added it
Traceback (most recent call last):
File "/home/amir/Workspace/mmb/recsysenv/lib/python3.6/site-packages/flask/app.py", line 2446, in wsgi_app
response = self.full_dispatch_request()
.
.
.
File "/usr/local/lib/python3.6/bdb.py", line 51, in trace_dispatch
return self.dispatch_line(frame)
File "/usr/local/lib/python3.6/bdb.py", line 69, in dispatch_line
self.user_line(frame)
File "/usr/local/lib/python3.6/pdb.py", line 261, in user_line
self.interaction(frame, None)
File "/home/amir/Workspace/mmb/recsysenv/lib/python3.6/site-packages/IPython/core/debugger.py", line 294, in interaction
OldPdb.interaction(self, frame, traceback)
File "/usr/local/lib/python3.6/pdb.py", line 352, in interaction
self._cmdloop()
File "/usr/local/lib/python3.6/pdb.py", line 321, in _cmdloop
self.cmdloop()
File "/home/amir/Workspace/mmb/recsysenv/lib/python3.6/site-packages/IPython/terminal/debugger.py", line 97, in cmdloop
line = self.pt_app.prompt() # reset_current_buffer=True)
File "/home/amir/Workspace/mmb/recsysenv/lib/python3.6/site-packages/prompt_toolkit/shortcuts/prompt.py", line 986, in prompt
return self.app.run()
File "/home/amir/Workspace/mmb/recsysenv/lib/python3.6/site-packages/prompt_toolkit/application/application.py", line 788, in run
return get_event_loop().run_until_complete(self.run_async(pre_run=pre_run))
File "/usr/local/lib/python3.6/asyncio/events.py", line 694, in get_event_loop
return get_event_loop_policy().get_event_loop()
File "/usr/local/lib/python3.6/asyncio/events.py", line 602, in get_event_loop
% threading.current_thread().name)
RuntimeError: There is no current event loop in thread 'Thread-1'.
After that I added threading snippet like that at the flask file
from threading import Thread
t = Thread(target=app, args=())
t.daemon = True
t.start()
t.join()
if __name__ == '__main__':
app.run()
but it raises
Traceback (most recent call last):
File "/usr/local/lib/python3.6/threading.py", line 916, in _bootstrap_inner
self.run()
File "/usr/local/lib/python3.6/threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
TypeError: __call__() missing 2 required positional arguments: 'environ' and 'start_response'
I tried both debug and non debug mode

ev3 closes connection when I attempt to connect through rpyc in python

I installed ev3dev on my ev3 brick so I could create programs on it with python. I am trying to use the "rpyc" library for python which can be found here. However, when I try to run this basic script which is given as an example on the link above:
import rpyc
conn = rpyc.classic.connect('192.168.137.3') # host name or IP address of the EV3
ev3 = conn.modules['ev3dev.ev3'] # import ev3dev.ev3 remotely
m = ev3.LargeMotor('outA')
m.run_timed(time_sp=1000, speed_sp=600)
I get multiple errors thrown at me through the terminal followed by the connection closing. I have followed all the instructions on the page and I also started the server script on the ev3 brick beforehand. When I run the above program the errors from python are displayed:
Traceback (most recent call last):
File "C:/Python27/cooode/moottertest.py", line 2, in <module>
conn = rpyc.classic.connect('192.168.137.3') # host name or IP address of the EV3
File "C:\Python27\lib\site-packages\rpyc\utils\classic.py", line 65, in connect
return factory.connect(host, port, SlaveService, ipv6 = ipv6)
File "C:\Python27\lib\site-packages\rpyc\utils\factory.py", line 90, in connect
return connect_stream(s, service, config)
File "C:\Python27\lib\site-packages\rpyc\utils\factory.py", line 51, in connect_stream
return connect_channel(Channel(stream), service = service, config = config)
File "C:\Python27\lib\site-packages\rpyc\utils\factory.py", line 40, in connect_channel
return Connection(service, channel, config = config)
File "C:\Python27\lib\site-packages\rpyc\core\protocol.py", line 147, in __init__
self._init_service()
File "C:\Python27\lib\site-packages\rpyc\core\protocol.py", line 150, in _init_service
self._local_root.on_connect()
File "C:\Python27\lib\site-packages\rpyc\core\service.py", line 145, in on_connect
self._conn.builtin = self._conn.modules.__builtin__
File "C:\Python27\lib\site-packages\rpyc\core\service.py", line 114, in __getattr__
return self[name]
File "C:\Python27\lib\site-packages\rpyc\core\service.py", line 111, in __getitem__
self.__cache[name] = self.__getmodule(name)
File "C:\Python27\lib\site-packages\rpyc\core\netref.py", line 196, in __call__
return syncreq(_self, consts.HANDLE_CALL, args, kwargs)
File "C:\Python27\lib\site-packages\rpyc\core\netref.py", line 71, in syncreq
return conn.sync_request(handler, oid, *args)
File "C:\Python27\lib\site-packages\rpyc\core\protocol.py", line 435, in sync_request
self.serve(0.1)
File "C:\Python27\lib\site-packages\rpyc\core\protocol.py", line 383, in serve
data = self._recv(timeout, wait_for_lock = True)
File "C:\Python27\lib\site-packages\rpyc\core\protocol.py", line 341, in _recv
data = self._channel.recv()
File "C:\Python27\lib\site-packages\rpyc\core\channel.py", line 50, in recv
header = self.stream.read(self.FRAME_HEADER.size)
File "C:\Python27\lib\site-packages\rpyc\core\stream.py", line 190, in read
raise EOFError("connection closed by peer")
EOFError: connection closed by peer
>>>
Then on my SSH session, here are the errors that are displayed:
robot#ev3dev:~$ ./rpyc_server.sh
INFO:SLAVE/18812:server started on [0.0.0.0]:18812
INFO:SLAVE/18812:accepted 192.168.137.1:5725
INFO:SLAVE/18812:welcome [192.168.137.1]:5725
INFO:SLAVE/18812:goodbye [192.168.137.1]:5725
ERROR:SLAVE/18812:client connection terminated abruptly
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/rpyc/utils/server.py", line 172, in _authenticate_and_serve_client
self._serve_client(sock2, credentials)
File "/usr/lib/python3/dist-packages/rpyc/utils/server.py", line 197, in _serve_client
conn._init_service()
File "/usr/lib/python3/dist-packages/rpyc/core/protocol.py", line 154, in _init_service
self._local_root.on_connect()
File "/usr/lib/python3/dist-packages/rpyc/core/service.py", line 150, in on_connect
self._conn.builtin = self._conn.modules.builtins
File "/usr/lib/python3/dist-packages/rpyc/core/service.py", line 121, in __getattr__
return self[name]
File "/usr/lib/python3/dist-packages/rpyc/core/service.py", line 118, in __getitem__
self.__cache[name] = self.__getmodule(name)
TypeError: 'b'instancemethod'' object is not callable
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python3.4/threading.py", line 920, in _bootstrap_inner
self.run()
File "/usr/lib/python3.4/threading.py", line 868, in run
self._target(*self._args, **self._kwargs)
File "/usr/lib/python3/dist-packages/rpyc/utils/server.py", line 172, in _authenticate_and_serve_client
self._serve_client(sock2, credentials)
File "/usr/lib/python3/dist-packages/rpyc/utils/server.py", line 197, in _serve_client
conn._init_service()
File "/usr/lib/python3/dist-packages/rpyc/core/protocol.py", line 154, in _init_service
self._local_root.on_connect()
File "/usr/lib/python3/dist-packages/rpyc/core/service.py", line 150, in on_connect
self._conn.builtin = self._conn.modules.builtins
File "/usr/lib/python3/dist-packages/rpyc/core/service.py", line 121, in __getattr__
return self[name]
File "/usr/lib/python3/dist-packages/rpyc/core/service.py", line 118, in __getitem__
self.__cache[name] = self.__getmodule(name)
TypeError: 'b'instancemethod'' object is not callable
What is going wrong here in these errors?
Are you connecting python2 and python3? ev3dev uses python2.
Use pyenv to install python3 and use it so that your python version of PC and ev3 are the same.
https://gist.github.com/jaydenkieran/75b2bbc32b5b70c4fdfb161ecdb6daa2
You might need to run this command first to install through curl:
sudo apt-get install curl

Categories

Resources