How do I send an image using file open with python an telepot? - telepot

I'm trying to send an image from my drive to telegram using the method sendPhoto but I can't. Which is the trick ?
I'm using Python 3.6.7 My code is as follows:
import sys
import telepot
import aiohttp
import asyncio
import os
import time
bot = telepot.Bot('55615????:AA????)
bot.getMe()
id=32????
bot.sendPhoto(chatId, str(open("th-623777.jpg", os.O_RDONLY)) )

Related

Missing Jar Files for HelloGlobe (JogAmp)

I am trying to run the following example.
I get errors for the following lines
import framework.Semantic;
import glm.mat.Mat4x4;
import glm.vec._2.Vec2;
import glm.vec._3.Vec3;
import uno.debug.GlDebugOutput;
import uno.glsl.Program;
...
import static glm.GlmKt.glm;
import static uno.buffer.UtilKt.destroyBuffer;
import static uno.buffer.UtilKt.destroyBuffers;
It seems that I am missing some more jar files even though I successfully imported jogl-all.jar and gluegen-rt.jar
I tried searching mvnrepository but did not find the jars I was looking for. I am not using maven.

javafx - MediaException: PLAYBACK_HALTED : DirectSoundCreate: (NULL)

I wanto to play a mp4 video inside of my java application. The software is running fine on my main PC where a sound card is installed. But on another PC with no sound device at all, this is the content of the player.getError:
MediaException: PLAYBACK_HALTED : DirectSoundCreate: (NULL)
This is a part of the code:
import java.awt.BorderLayout;
import java.io.File;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Mixer.Info;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import javafx.embed.swing.JFXPanel;
import javafx.scene.Scene;
import javafx.scene.layout.StackPane;
import javafx.scene.media.Media;
import javafx.scene.media.MediaPlayer;
import javafx.scene.media.MediaView;
Media m = new Media(file.toURI().toString());
MediaPlayer player = new MediaPlayer(m);
MediaView viewer = new MediaView(player);
player.setAutoPlay(true);
player.setCycleCount(MediaPlayer.INDEFINITE);
player.setOnError(()->Logging.getLogger().log("MediaPlayer setOnError: " + player.getError().toString(),Message.MESSAGE));
I can provide more code, if necessary. Once before I provided too much code and got bad comments about that.
My questions, how can I configure javaFX media player or one of it's components to run the video without a sound device. There must be something to configure. But I do not know.
Edit:
I was checking the versions of javafx on both PCs:
System.out.print(com.sun.javafx.runtime.VersionInfo.getRuntimeVersion());
8.0.311-b11 (Office PC where the code is working)
8.0.201-b08 (Shopfloor PC where the code is not working)
Edit:
I have installed a virtual sound card on the shopfloor PC. The error message disappeared. But no video is playing. No error message is showing. No exception is showing.
I need to get in contact with out MES supplier, because my java code on the shopfloor PC is running inside of a MES system.
(MES = Manufacturing Execution System)

How to start Bokeh server programmatically in dev / debug mode

I'm still developing my project and I want to make a lot of changes to UI through HTML/CSS, I'm starting the Bokeh server programmatically and it looks like this:
from tornado.ioloop import IOLoop
from tornado.web import StaticFileHandler
from bokeh.server.server import Server
from bokeh.application import Application
from bokeh.application.handlers.function import FunctionHandler
from os.path import dirname, join
import sys
if not dirname(__file__) in sys.path: sys.path.append(dirname(__file__))
from models.ProjectDataLoading import modify_page1
from models.Empty import modify_page2
page1_app = Application(FunctionHandler(modify_page1))
page2_app = Application(FunctionHandler(modify_page2))
StaticFileHandler.reset()
io_loop = IOLoop.current()
server = Server(applications = {'/ProjectDataLoading': page1_app,
'/PrimaveraObjects': page2_app,
'/SpecializedReports': page2_app,
'/StatisticalReports': page2_app,
'/Predictions': page2_app},
extra_patterns=[(r'/static/css/(.*)', StaticFileHandler, {'path':join(dirname(__file__),"static","css")})],
io_loop = io_loop, port = 5006, static_hash_cache=False, debug=True, autoreload=True, compiled_template_cache=False, serve_traceback=True)
server.start()
server.show('/ProjectDataLoading')
io_loop.start()
I'm still working on page1 -> "ProjectDataLoading", and as you can see I'm trying to make the server to stop cashing the static files with the following codes:
StaticFileHandler.reset()
static_hash_cache=False
debug=True
of course, it's wrong, because it's related to tornado application, not Bokeh server, so, how can I do it Bokeh server?
Almost all the code to support dev mode, i.e. watching a list file files and auto-reloading, is in the application part of the Bokeh server, not in the library. So you would need to essentially reproduce the code here:
https://github.com/bokeh/bokeh/blob/8f9cf0a85ba51098da2d027150e900bfc073eeba/bokeh/command/subcommands/serve.py#L785-L816

How to use my own file as a default module in Python3?

import myfile
function1(2,3,4)
How can i use my file as a default module so that I can use it just by entering import myfilename without specifying
import sys
sys.path.insert(0 ,'/dir1/dir2')
import myfile
myfile.function1()

Qpython import modules in script

I have installed qpython for android, the problem is that when I install a module with pip in the python console I can import it properly, but not when I try to import it to a script.
in console ... I type:
>>>import requests
>>>requests
<module 'requests' from '/data/data/com.hipipal.qpyplus/.../__init__.py>
but in a script saved in scripts' folder, when I execute:
import requests
r = requests.get("http://www.google.com")
print r.text.encode('utf-8')
I get this:
import requests
ImportError: no module named requests
Can anybody help with that?
Thank you!
Add import site.
This works on my tablet:
#-*-coding:utf8;-*-
#qpy:2
#qpy:console
import site
import requests
r = requests.get("http://www.google.com")
print r.text.encode('utf-8')

Resources