On 14/05/18 22:20, mm0fmf wrote:
> On 14/05/2018 20:49, RobH wrote:
>> On 14/05/18 20:42, mm0fmf wrote:
>>> On 14/05/2018 20:23, RobH wrote:
>>>> I have built a motion sensor detector using this code: from the
>>>> dronebotworkshop on youtube. While it works very well for me, I now
>>>> want
>>>> to upload the pictures to my NAS server.
>>>> I googled this and found this line of code:
>>>>
>>>> curl -T /home/pi/filename.jpg
>>>> ftp://ftp-host-machine//yourwebsite/folder/filename.jpg --user
>>>>
>>>> Now when I run the python script:
>>>>
>>>> from picamera import PiCamera
>>> [snip]
>>>
>>>> curl -T /home/pi/filename.jpg ftp://ftp-ipaddressof NAS
>>>> server/mnt/folder/filename.jpg --user
>>>> # Wait 25 seconds and repeat
>>>> time.sleep(25)
>>>>
>>>> It returns Invalid syntax at the ftp://ftp- etc
>>>>
>>>> I can get as far as a login box from my Ubuntu desktop with this:
>>>> ftp://server ip address/mnt/Folder/subfolder, but it fails
>>>> completely on
>>>> the PiZero with invalid synatx at ftp
>>>
>>> curl is not a Python command but an external program. You either need
>>> to use pycurl (a la import pycurl) or you want to get your Python
>>> script to execute the curl program using os.system(....) or similar.
>>>
>>> Much more simple would be to use the ftp library included in the
>>> standard Python library and do the ftp yourself. YMMV.
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>> Thanks, but when the python script runs without the inserted curl line,
>> it takes pictures of whatever is sensed and writes the actual file to
>> the sdcard.
>>
>> I read somewhere that writing to the Pizero sdcard so many times, as it
>> would, is not a could idea as it could be corrupted.
>>
>> So I looked for a way to upload the jpg file to my server.
>
> Well curl is a program not a Python method. So you have to tell Python
> to execute curl with os.system() or similar or you can use the curl
> library pycurl or use ftplib. An example for Python2 on Windows, edit to
> fit.
>
> import ftplib
> from ftplib import FTP
>
> File2Send = "V://GIS//Maps//County//11x17shd//2010BEAVER11x17shd.pdf"
> Output_Directory = "//data2//ftp//pub//download//maps//"
>
> try:
> ftp = FTP("XXX.XXX.XXX.XXX")
> ftp.login(username, password)
> file = open(File2Send, "rb")
> ftp.cwd(Output_Directory)
> ftp.storbinary('STOR ' + File2Send, file)
> print "STORing File now..."
> ftp.quit()
> file.close()
> print "File transfered"
> else:
> print "An error occured"
>
>
> See https://community.esri.com/thread/16333
>
>
Thanks for the above but when I use import ftplib, it returns
bash: import: command not found.
--- SoupGate-Win32 v1.05
* Origin: Agency HUB, Dunedin - New Zealand | FidoUsenet Gateway (3:770/3)
|