Rob- thanks for the awesome work on your SFTP mod. 

One issue the mod has is that it doesn't create directories on the remote 
server if they don't exist. Easily fixed though. I'll upload my fix to 
github, or email me off-list if you need it in the meantime.

The gist is:

Search for this section in the modified ftpupload.py from 
https://github.com/RobCranfill/weewx/blob/master/bin/weeutil/ftpupload.py:

               # Make the remote directory if necessary:
                if self.useSFTP:

                    # FIXME this doesn't create the remote dir if it 
doesn't exsit
                    # syslog.syslog(syslog.LOG_DEBUG, "ftpupload: change 
remote dir to %s" % remote_dir_path)
                    sftp.chdir(remote_dir_path)


And change to:


               # Make the remote directory if necessary:
                if self.useSFTP:

                    try: sftp.makedirs(remote_dir_path)
                    except Exception, e: syslog.syslog(syslog.LOG_NOTICE, 
"ftpupload: Unable to create directories on the remote server %s" % e)
            
                    # Not sure if this is still necessary:
                    sftp.chdir(remote_dir_path)
 




On Friday, October 30, 2015 at 7:31:56 AM UTC-7, Rob Cranfill wrote:
>
> Radoslav,
>
> I am the author of that branch, and I am sorry that didn't work for you. I 
> am not a Python expert by any means, so I am not sure what the problem is - 
> and I see from your next message that you have found a work-around that 
> doesn't require my code at all, so perhaps the point is moot. The only 
> thing I can think of is noting that you do need to make sure the "pysftp" 
> library is available (which, if I'm reading the stack trace correctly, it 
> does look like it's there.) Perhaps 
> http://pysftp.readthedocs.org/en/release_0.2.8/index.html 
> would have some clues.
>
> But thanks for at least trying my code! :-)
>
>  /rob
>
>
>
> On Tuesday, October 27, 2015 at 9:32:59 AM UTC-7, Radoslav Fatura wrote:
>>
>> Well, something is missing... 
>>
>>> Oct 27 17:31:19 raspberrypi weewx[582]: ftpupload: Attempting SFTP 
>>>> connection to sosst.tk
>>>
>>> Oct 27 17:31:29 raspberrypi weewx[582]: reportengine: Caught exception 
>>>> <type 'exceptions.IOError'> in FtpGenerator; [Errno 2] No such file.
>>>
>>> Oct 27 17:31:30 raspberrypi weewx[582]:         ****  Traceback (most 
>>>> recent call last):
>>>
>>> Oct 27 17:31:30 raspberrypi weewx[582]:         ****    File 
>>>> "/home/weewx/bin/weewx/reportengine.py", line 212, in run
>>>
>>> Oct 27 17:31:30 raspberrypi weewx[582]:         ****      N = 
>>>> ftpData.run()
>>>
>>> Oct 27 17:31:30 raspberrypi weewx[582]:         ****    File 
>>>> "/home/weewx/bin/weeutil/ftpupload.py", line 164, in run
>>>
>>> Oct 27 17:31:30 raspberrypi weewx[582]:         ****     
>>>>  sftp.chdir(remote_dir_path)
>>>
>>> Oct 27 17:31:30 raspberrypi weewx[582]:         ****    File 
>>>> "/home/weewx/bin/weeutil/pysftp.py", line 510, in chdir
>>>
>>> Oct 27 17:31:30 raspberrypi weewx[582]:         ****     
>>>>  self._sftp.chdir(remotepath)
>>>
>>> Oct 27 17:31:30 raspberrypi weewx[582]:         ****    File 
>>>> "/usr/lib/python2.7/dist-packages/paramiko/sftp_client.py", line 580, in 
>>>> chdir
>>>
>>> Oct 27 17:31:30 raspberrypi weewx[582]:         ****      if not 
>>>> stat.S_ISDIR(self.stat(path).st_mode):
>>>
>>> Oct 27 17:31:30 raspberrypi weewx[582]:         ****    File 
>>>> "/usr/lib/python2.7/dist-packages/paramiko/sftp_client.py", line 413, in 
>>>> stat
>>>
>>> Oct 27 17:31:30 raspberrypi weewx[582]:         ****      t, msg = 
>>>> self._request(CMD_STAT, path)
>>>
>>> Oct 27 17:31:30 raspberrypi weewx[582]:         ****    File 
>>>> "/usr/lib/python2.7/dist-packages/paramiko/sftp_client.py", line 729, in 
>>>> _request
>>>
>>> Oct 27 17:31:30 raspberrypi weewx[582]:         ****      return 
>>>> self._read_response(num)
>>>
>>> Oct 27 17:31:30 raspberrypi weewx[582]:         ****    File 
>>>> "/usr/lib/python2.7/dist-packages/paramiko/sftp_client.py", line 776, in 
>>>> _read_response
>>>
>>> Oct 27 17:31:30 raspberrypi weewx[582]:         ****     
>>>>  self._convert_status(msg)
>>>
>>> Oct 27 17:31:30 raspberrypi weewx[582]:         ****    File 
>>>> "/usr/lib/python2.7/dist-packages/paramiko/sftp_client.py", line 802, in 
>>>> _convert_status
>>>
>>> Oct 27 17:31:30 raspberrypi weewx[582]:         ****      raise 
>>>> IOError(errno.ENOENT, text)
>>>
>>> Oct 27 17:31:30 raspberrypi weewx[582]:         ****  IOError: [Errno 2] 
>>>> No such file
>>>
>>>
>>>

-- 
You received this message because you are subscribed to the Google Groups 
"weewx-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to weewx-user+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to