Go to advanced search

by ghp
Sat Aug 17, 2019 5:47 pm
Forum: Python
Topic: Quckest Bootable OS For Python Scripts ?
Replies: 1
Views: 45

Re: Quckest Bootable OS For Python Scripts ?

for starting a program at startup, see
https://www.dexterindustries.com/howto/ ... t-startup/

Your script "its ascript which when a input is pressed it triggers a gpio " needs console input, or gpio input ?
If only GPIO is needed, use systemd to start.
by ghp
Sat Aug 17, 2019 5:40 pm
Forum: Python
Topic: No data written in CSV file
Replies: 3
Views: 63

Re: No data written in CSV file

change the code a bit and ensure file is closed after each write. while True: with open("humidity.csv", "a+") as log: ... read sensor value ... d = "{0},{1}\n".format(strftime("%Y-%m-%d %H:%M:%S"),str(humidity)) print(d) log.write(d) sleep(1) The "a+" is 'append or create if not available'.
by ghp
Fri Aug 16, 2019 6:08 pm
Forum: Python
Topic: How to separate the body of the email in Gmail (like 1 email 1 body)?
Replies: 4
Views: 151

Re: How to separate the body of the email in Gmail (like 1 email 1 body)?

Hello, the problem with the growing text could be that the mail object is build in main code once, and in sending the mail some text is attached each time. mail = MIMEMultipart() mail['From'] = fromaddr mail['To'] = toaddr mail['Subject'] = "[Intruder Alert] Motion Detected!" body = "Who is the Intr...
by ghp
Mon Aug 12, 2019 7:59 pm
Forum: Python
Topic: reading a online database but have a fall over on the pi ?
Replies: 7
Views: 216

Re: reading a online database but have a fall over on the pi ?

https://stackoverflow.com/questions/139 ... d-the-cont

Surround this with a try:...except Exception: and read the file in the exception branch.
by ghp
Mon Aug 12, 2019 4:57 pm
Forum: Python
Topic: GPIO Input doesn't work
Replies: 8
Views: 216

Re: GPIO Input doesn't work

Ups, my fault. Think here is a good reference ?
https://elinux.org/RPi_Low-level_peripherals#P1_Header
by ghp
Mon Aug 12, 2019 4:45 pm
Forum: Python
Topic: GPIO Input doesn't work
Replies: 8
Views: 216

Re: GPIO Input doesn't work

See https://raspberrypi.stackexchange.com/questions/12966/what-is-the-difference-between-board-and-bcm-for-gpio-pin-numbering BCM 1 is on pin 28 of the header and not available on the 'old' PI generations. There is also a graphical tool like https://pinout.xyz/# BCM 17, 27, 22. 23. 24 are a good cho...
by ghp
Sun Aug 11, 2019 12:38 pm
Forum: Python
Topic: Old-school GUI - Possible? (Beware, silly purpose)
Replies: 25
Views: 790

Re: Old-school GUI - Possible? (Beware, silly purpose)

svg is handy to produce lines, blocks, text. svg can be included in html. <html><body><svg>...elements...</svg></body></html> In tornado, the Handler methods can produce svg on the fly, using Elementtree and then convert to string and paste into the html. Assume a set of methods which build labels, ...
by ghp
Sat Aug 10, 2019 3:45 pm
Forum: Python
Topic: My python program respond responding very slow as time goes on
Replies: 14
Views: 469

Re: My python program respond responding very slow as time goes on

Could you give some details about the solution found ?
by ghp
Sat Aug 10, 2019 3:21 pm
Forum: Python
Topic: Old-school GUI - Possible? (Beware, silly purpose)
Replies: 25
Views: 790

Re: Old-school GUI - Possible? (Beware, silly purpose)

still looking for technologies or solutions ?
Screenshot_2019-08-10.png
Screenshot_2019-08-10.png (4.42 KiB) Viewed 428 times
produced in html, using embedded svg. The generating code is python in tornado simulating block graphics. The input field is embedded html input field.
by ghp
Sat Aug 10, 2019 8:27 am
Forum: Python
Topic: For some reason my code presses random buttons
Replies: 3
Views: 152

Re: For some reason my code presses random buttons

Did not know the "webbrowser" module so far. Nice module. Sending ctrl-w to this browser only works when the browser has the focus. Whenever it is in background, the keyboard event will not arrive. This resulted in additional tabs opened in some cases. Here on my pi, the webbrowser.open calls 'epiph...
by ghp
Sat Aug 10, 2019 7:49 am
Forum: Python
Topic: Running Python Scripts From A Html
Replies: 36
Views: 740

Re: Running Python Scripts From A Html

Think tornado can't achieve to change a web page in a browser after some seconds. ** This requirement needs javascript in the page. Found https://www.tutorialspoint.com/How-to-use-JavaScript-to-redirect-a-webpage-after-5-seconds The code snippet from there is <!DOCTYPE html> <html> <body> <script> s...
by ghp
Thu Aug 08, 2019 4:41 pm
Forum: Python
Topic: Running Python Scripts From A Html
Replies: 36
Views: 740

Re: Running Python Scripts From A Html

StaticFileHandler is a good choice for the start page.
If you need images or css files, add appropriate url-pathes too.
by ghp
Wed Aug 07, 2019 5:12 pm
Forum: Python
Topic: Running Python Scripts From A Html
Replies: 36
Views: 740

Re: Running Python Scripts From A Html

Think the two scripts opendoor_1.py, opendoor_2.py are not available in local directory. Either rename the scripts you have to these names, or adjust the calls in the Handlers. The code fragment is Python3ScriptRunner().invoke( "opendoor_1.py") or Python3ScriptRunner().invoke( "opendoor_2.py"). In m...
by ghp
Tue Aug 06, 2019 8:05 pm
Forum: Python
Topic: Running Python Scripts From A Html
Replies: 36
Views: 740

Re: Running Python Scripts From A Html

think this could work import tornado.ioloop import tornado.web import subprocess import os class Python3ScriptRunner: def __init__(self): pass def invoke(self, script_name): print("call script ", script_name) if os.path.isfile(script_name): pid = subprocess.Popen(["/usr/bin/python3", script_name]).p...
by ghp
Mon Aug 05, 2019 5:05 am
Forum: Python
Topic: Old-school GUI - Possible? (Beware, silly purpose)
Replies: 25
Views: 790

Re: Old-school GUI - Possible? (Beware, silly purpose)

Block graphics can be build with "curses", a python library. But the large font for the 'company name' is possibly not supported.
by ghp
Mon Aug 05, 2019 4:35 am
Forum: Python
Topic: Running Python Scripts From A Html
Replies: 36
Views: 740

Re: Running Python Scripts From A Html

- the last line of code is missing tornado.ioloop.IOLoop.current().start() - html code usually has links inside <body>... here goes the page ...</body>. Your page works unexpectedly. - in the Popen, add ", shell=True". Or try using /usr/bin/python which is more precise. - the url mappings contain r"...
by ghp
Sun Aug 04, 2019 5:33 pm
Forum: Python
Topic: problem connect epsolar-tracer to raspberry pi
Replies: 15
Views: 328

Re: problem connect epsolar-tracer to raspberry pi

The cable has an USB device build in, but unfortunately I can't find more information for this vendor-product. Found a page which provides a driver for this sort of devices https://github.com/kasbert/epsolar-tracer/tree/master/xr_usb_serial_common-1a And someone who wired the device directly. https:...
by ghp
Sun Aug 04, 2019 11:29 am
Forum: Python
Topic: Running Python Scripts From A Html
Replies: 36
Views: 740

Re: Running Python Scripts From A Html

Brackets come in pairs.
by ghp
Sun Aug 04, 2019 10:14 am
Forum: Python
Topic: Problem with my OLED time, date, weather script.
Replies: 6
Views: 200

Re: Problem with my OLED time, date, weather script.

Code: Select all

    data = json.loads(response.read())
    print("data from response is", data)  # add this statement and look what the data structure is
    temp = data['main']['temp']
by ghp
Sun Aug 04, 2019 8:30 am
Forum: Python
Topic: Running Python Scripts From A Html
Replies: 36
Views: 740

Re: Running Python Scripts From A Html

how would it be possible to open a .html file i have already created when the "Release Door" link is pressed? Static files can be handled with (drum fill) StaticFileHandler. return tornado.web.Application([ ( r"/", MyFormHandler ), ( r"/myform", MyFormHandler ), ( r"/sample", MySampleHandler ), ( r...
by ghp
Sat Aug 03, 2019 4:55 pm
Forum: Python
Topic: Running Python Scripts From A Html
Replies: 36
Views: 740

Re: Running Python Scripts From A Html

The link in the html page <a href="/sample">a sample link</a> is using url "/sample". The url resolution table in the code ( r"/", MyFormHandler), ( r"/myform", MyFormHandler), ( r"/sample", MySampleHandler), links /sample to MySampleHandler. You know about http-requests: a link is a using a GET-req...
by ghp
Sat Aug 03, 2019 4:03 pm
Forum: Python
Topic: Running Python Scripts From A Html
Replies: 36
Views: 740

Re: Running Python Scripts From A Html

Hello, this handler MyFormHandler with its post method is dedicated to the form in the html. Think you spotted the url mapping to the handlers in the code ( r"/", MyFormHandler), ( r"/myform", MyFormHandler), ( r"/sample", MySampleHandler), The method names correspond to the GET, POST, ... request n...
by ghp
Sat Aug 03, 2019 11:03 am
Forum: Python
Topic: Running Python Scripts From A Html
Replies: 36
Views: 740

Re: Running Python Scripts From A Html

Hello, in the Handler for the link, add import subprocess Good if the python script executes fast. subprocess.run("python3 test1.py", shell=True) For long running scripts, you should spawn the process. pid = subprocess.Popen(["python3", "test1.py"]).pid print(pid) # pid allows to terminate the proce...
by ghp
Sat Aug 03, 2019 10:22 am
Forum: Python
Topic: Running Python Scripts From A Html
Replies: 36
Views: 740

Re: Running Python Scripts From A Html

unfortunately there is the python2-python3 confusion.
For python3, install and run with

# recommended, as Tornado 6.0 requires Python 3.5.2
sudo pip3 install tornado
python3 tornado1.py
by ghp
Sat Aug 03, 2019 7:01 am
Forum: Python
Topic: problem connect epsolar-tracer to raspberry pi
Replies: 15
Views: 328

Re: problem connect epsolar-tracer to raspberry pi

Hello, the /dev/ttyACM0 is available on my system too. With 'lsusb', you find out some more details about vendorid, productid of usb devices. Here the partial output on a system with an arduino uno and a common FTDI chip Bus 001 Device 006: ID 0403:6001 Future Technology Devices International, Ltd F...

Go to advanced search