I've been playing around with Motion on my Rapsberry Pi running Raspbian and came across this post that sounded like fun to do.
I've been trying to tweak the steps he lists to have it work with Raspbian, and as far as I know I should be good. I installed GData using "sudo apt-get install python-gdata" And then I put the uploader.py and uploader.cfg files in /etc/motion and changed the motion.confg file to have the line
on_movie_end /etc/motion/uploader.py /etc/motion/uploader.cfg %f
Am I missing something? Theoretically this should work on Raspbian right? What else has to be done?
Thanks
I have been following the guides you have referred to get this working on Raspbian and I had the same problem; Motion seems to work but the script never executes.
However, when i tried to run the script directly I got a permission error.
I ran the following to make the script executable.
chmod a+x /etc/motion/uploader.py
now it uploads the videos to Google drive (no emails though?)
hope this helps,
This isn't a direct answer to your question, but it might be a away of getting files uploaded to google drive in an easier way.
Have you had a look at grive, its a linux utility which can be used to sync a folder on your raspberry pi with a folder on google drive.
See this link for more info on how to setup and use grive on a raspberry pi.
http://www.stuffaboutcode.com/2013/03/raspberry-pi-google-drive-grive.html
I also struggled with it quite a bit and this is what helped. First try to run this from terminal:
/etc/motion/uploader.py /etc/motion/uploader.cfg /
Here you put the absolute path to your file you want to upload.
Try to run it, and if it asks you for a password you know you have a permission problem and need to change permissions so that it does not require the password to execute.
Try again. If it works then it will also work if you use this in uploader.cfg:
on_movie_end /etc/motion/uploader.py /etc/motion/uploader.cfg %f
Do not forget to uncomment this line! This sounds silly but it took me some time to realize it, i.e. delete ; that is in front of on_movie_end.
Another issue I had was the movie encoding. Only mpeg4 really worked for me.
Related
It must be very simple, but somehow I am missing something... Apologies for the long message but it's driving me crazy.
I'm reading thinkstat2, a free pdf about statistics for data science (beginner level).
It comes with exercises so I'm trying to follow the instructions and import the data. I'll describe the steps I'm following and give the pages, it's like a 2 minutes read.
Step 1a: Page 8 - "0.2 Using the code" - Get the code from author's github. I don't have a github account, so I dl the code as a zip on my hard drive. Then I extracted the content in a new folder.
Step 1b: Page 9 - Author suggests to get anaconda. From my understanding, anaconda contains many different app you can use through the "anaconda navigator". I have anaconda and will use Jupyter notebook for this.
Step 2: Page 9 - Author asks to run "nsfg.py" from his zip to make sure the reader has all the packages installed. Author says I should have a confirmation message. When I run it, there's a flash of command screen without any error or confirmation message. But if it's all about checking that the right package are installed correctly, I can just add "import x" in my code to add the missing package, so not a real issue here (or so I believed). I moved on.
Step 3: Pages 24 to 26 - "1.3 Importing the data" and "1.4 Dataframes" - This is where I'm stuck. After running "nsfg.py" (I mentioned in step 2), the author asks to "import nsfg", which is his own package created from "nsfg.py"? Maybe? So I try to import it and it's not recognized. Which probably comes from that "not a real issue" in step 2... I checked inside "nsfg.py" and it seems to be code to clean and read a .dct and .gz file.
Questions:
I don't understand what I'm supposed to do to make "nsfg.py" run properly.
I don't understand how my jupyter notebook would understand the "import nsfg" since those lies on my hard drive. The author does not add any line regarding importing anything from a local drive, or from a url to his github (not in the code of nsfg.py as well, except if I missed it).
I thought about just copy pasting the code of "nsfg.py" and running it, but I believe it would not work since the .dct and .gz file mentioned are saved locally as well. So I don't get how the code pasted from nsfg.py I run on jupyter notebook would make a link with those local .dct and .gz files. My python is not advanced enough to tinker that manually...
Help :( (any alternative solution is welcome)
Two ways to solve this, both worked for me:
Firstly, to replicate what the extracts of the book say, all assuming you are using linux or mac:
Hit git clone https://github.com/AllenDowney/ThinkStats2.git in your terminal in whatever folder you want to wok in
Then cd ThinkStats2/code.
Then python nsfg.py
Then hit python again to give you an interactive shell which is what the author of the book appears to be using - note the >>> before each command which indicates that it isn't in a Jupyter notebook.
To get this to work in a Jupyter notebook:
Hit git clone https://github.com/AllenDowney/ThinkStats2.git in your terminal in whatever folder you want to wok in
In your jupyter notebook interface, create a new notebook in the same directory as the ThinkStats2/code folder.
In the notebook hit import nsfg.
I think you are probably getting errors because you are not running your notebook from the same directory as the nsfg.py file which means that python can't find the script and so can't import it.
So I just created a simple script with selenium that automates the login for my University's portal. The first reaction I got from a friend was: ah nice, you can put that on my pc as well. That would be rather hard as he'd have to install python and run it through an IDE or through his terminal or something like that and the user friendliness wouldn't be optimal.
Is there a way that I could like wrap it in a nicer user interface, maybe create an app or something so that I could just share that program? All they'd have to do is then fill in their login details once and the program then logs them in every time they want. I have no clue what the possibilities for that are, therefore I'm asking this question.
And more in general, how do I get to use my python code outside of my IDE? Thusfar, I've created some small projects and ran them in PyCharm and that's it. Once again, I have no clue what the possibilities are so I also don't really know what I'm asking. If anyone gets what I mean by using my code further than only in my IDE, I'd love to hear your suggestions!
The IDE running you program is the same as you running your program in the console. But if you dont want them to have python installed (and they have windows) you can maybe convert them to exe with py2exe. But if they have linux, they probably have python installed and can run you program with "python script.py". But tell your friends to install python, if they program or not, it will always come in handy
During a presentation yesterday I had a colleague run one of my scripts on a fresh installation of Python 3.8.1. It was able to create and write to a csv file in his folder (proof that the csv library was working correctly), but everything else failed due to not being able to find the needed files. To try and isolate the problem and figure out why, we tried the below simple script, which also failed.
He had this test.py script in "D:/TEST", which also contained some folders and image files. Running this script printed nothing to the console. No empty list, no error message, no newline. Maybe the print() function was also not working, but I didn't get around to testing that.
import os
print(os.listdir())
This script works fine on my computer and my other colleagues computers (all Windows 10, similar hardware). I didn't have time to look into the issue more thoroughly and don't have access to his computer anymore. What could be the problem? What other things could I have him look into in order to fix this? In case this problem appears again during a future presentation, what steps could I take to figure out the cause of it?
My colleague uninstalled Python and reinstalled it. After doing this apparently the "python" command will no longer run his scripts, but using "py" instead will. Now that he is using "py" to run his scripts, it is working as expected.
I've setup Geany a long time ago to compile my Python program on my Windows machine which it then sends to my Pi via scp. It still works fine - but if I take the same file and rename it, it refuses to do it.
I get "scp: /home/pi/scripts/APC2.py: Permission denied" from the Compiler in the MEssage window
And really don't want all my programs called the same thing.
I basically can't remember how I did the setup and can't find it anywhere on the internet.
Any help will be greatly appreciated
I found the link again:
http://www.python-exemplary.com/index_en.php?inhalt_links=navigation_en.inc.php&inhalt_mitte=raspi/en/installation.inc.php
Also my permissions for the new file were incorrect as Geany sends the file to /home/pi/scripts and I log in as root and not the pi user.
I'm trying to run python (version 2.7.2) on my computer (windows vista 32bit). It's always worked until now when Idle just does not respond to any commands.
Any commands entered (even very simple ones) have no output/do not get computed! See image:
Python works fine when I run it using command line though!
I've tried re-installing it a few times but it just doesn't help! Also tried running it from C:\Python27\Lib\idlelib\idle.py and I get the following message before the same unresponsive IDLE pops up again! See image:
Any help would be greatly appreciated.
Thanks
Try
print 1+2
You need to do something with the result.
A few suggestions:
IDLE starts a subprocess and connects to it over TCP port 8833. Is this port being blocked by a firewall on your computer?
Are there any files whose name clash with built-in Python modules? This page mentions problems with files called string.py.
Is the file config-keys.def under C:\Python27\Lib\idlelib missing or does it have its permissions set so that nobody can read it? I found that if I removed this file or restricted the permissions on it, IDLE became unresponsive as you described. If I then replaced it or reset the permissions, IDLE started working again. (Other config-*.def files in this folder might also need to be checked.)
This looks like the bug described here: http://bugs.python.org/issue14409
Your config file for key bindings is corrupt. Try renaming your ~/.idlerc folder to something else and restart IDLE.