omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    Python SMB Connection

    Pythonista
    3
    85
    24325
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • DavinE
      DavinE @cvp last edited by

      @cvp said:

      @DavinE FTP is ok and SFTP (SSH) also

      SFTP i don't know it works because i use Private Key's for my SSH connection...

      1 Reply Last reply Reply Quote 0
      • cvp
        cvp @DavinE last edited by

        @DavinE upload or download?

        DavinE 1 Reply Last reply Reply Quote 0
        • DavinE
          DavinE @cvp last edited by

          @cvp said:

          @DavinE upload or download?

          upload ;)

          cvp 1 Reply Last reply Reply Quote 0
          • cvp
            cvp @DavinE last edited by cvp

            @DavinE try first this

            from ftplib import FTP
            ip = '192.168.0.47'
            user = 'admin'
            pwd = 'xxxxxxx''
            ftp = FTP(ip) #connect
            ftp.encoding = 'utf-8'
            ftp.login(user,pwd)
            ftp.retrlines('NLST *')
            ftp.quit()
            
            DavinE 1 Reply Last reply Reply Quote 0
            • cvp
              cvp last edited by

              Upload

              ftp = FTP(ip) #connect
              ftp.encoding = 'utf-8'
              ftp.login(user,pwd)
              local_file = open(path,'rb')
              ftp.storbinary('STOR '+server_file, local_file, blocksize=32768)
              local_file.close()
              ftp.quit()
              
              DavinE 1 Reply Last reply Reply Quote 0
              • cvp
                cvp @DavinE last edited by

                @DavinE said:

                I'm annoying you a lot,

                Not at all, but less available tonight

                1 Reply Last reply Reply Quote 1
                • DavinE
                  DavinE @cvp last edited by

                  @cvp said:

                  from ftplib import FTP
                  import paramiko
                  

                  ftplib for FTP
                  paramiko for SFTP

                  There is also FTPS is that better for security?
                  how can i use this with Ports ?

                  from ftplib import FTP_TLS
                  
                  ftp = FTP_TLS()
                      ftp.ssl_version = ssl.PROTOCOL_SSLv23
                      ftp.ssl_version = ssl.PROTOCOL_TLSv1_2
                      ftp.debugging = 2
                      ftp.connect('localhost', 2121)
                      ftp.login('developer', 'password')
                      return ftp
                  

                  but which version TLS or SSL ?

                  cvp 1 Reply Last reply Reply Quote 0
                  • DavinE
                    DavinE @cvp last edited by

                    @cvp said:

                    @DavinE try first this

                    from ftplib import FTP
                    ip = '192.168.0.47'
                    user = 'admin'
                    pwd = 'xxxxxxx''
                    ftp = FTP(ip) #connect
                    ftp.encoding = 'utf-8'
                    ftp.login(user,pwd)
                    ftp.retrlines('NLST *')
                    ftp.quit()
                    

                    This works :D ^^
                    i see my Shared Folders ;)

                    1 Reply Last reply Reply Quote 0
                    • DavinE
                      DavinE @cvp last edited by

                      @cvp said:

                      Upload

                      ftp = FTP(ip) #connect
                      ftp.encoding = 'utf-8'
                      ftp.login(user,pwd)
                      local_file = open(path,'rb')
                      ftp.storbinary('STOR '+server_file, local_file, blocksize=32768)
                      local_file.close()
                      ftp.quit()
                      

                      server_file
                      is this this the storage Path ?

                      cvp 1 Reply Last reply Reply Quote 0
                      • cvp
                        cvp @DavinE last edited by

                        @DavinE yes sir, but it may begin at first folder where you are authorized. try first without folder, only a file name to check after upload where it has been stored

                        DavinE 1 Reply Last reply Reply Quote 0
                        • cvp
                          cvp @DavinE last edited by

                          @DavinE said:

                          There is also FTPS is that better for security?
                          how can i use this with Ports ?

                          from ftplib import FTP_TLS

                          ftp = FTP_TLS()
                          ftp.ssl_version = ssl.PROTOCOL_SSLv23
                          ftp.ssl_version = ssl.PROTOCOL_TLSv1_2
                          ftp.debugging = 2
                          ftp.connect('localhost', 2121)
                          ftp.login('developer', 'password')
                          return ftp
                          but which version TLS or SSL ?

                          Never used. If needed, I use SFTP

                          1 Reply Last reply Reply Quote 0
                          • DavinE
                            DavinE @cvp last edited by

                            @cvp said:

                            @DavinE yes sir, but it may begin at first folder where you are authorized. try first without folder, only a file name to check after upload where it has been stored

                            @cvp really thanks a lot for your help!! and for your Time to help me out ;) Thanks!!

                            i played now a while and it works like i will create folders upload files etc. great!!

                            beautiful evening @cvp xD

                            cvp 1 Reply Last reply Reply Quote 0
                            • cvp
                              cvp @DavinE last edited by

                              @DavinE 👍

                              1 Reply Last reply Reply Quote 1
                              • DavinE
                                DavinE last edited by

                                @cvp
                                I Have a Problem...

                                I used this code:

                                self.subDirCustomer_Prüfungen = 'Prüfungen'
                                self.cur.encoding = 'utf-8'
                                self.cur.mkd(self.subDirCustomer_Prüfungen) 
                                

                                But i get this Output folder Prüfungen
                                How can i tell mkd to use the utf-8....

                                Do you know That ?

                                cvp 2 Replies Last reply Reply Quote 0
                                • cvp
                                  cvp @DavinE last edited by cvp

                                  @DavinE sincerely, I don't know. I got the same kind of problems with accents like é, è, à on some, not all, machines I connect in smb. To avoid this, I don't use anymore accents in my folder/file names

                                  Edit : even 10 years ago, this kind problem did already exist, see here

                                  1 Reply Last reply Reply Quote 0
                                  • DavinE
                                    DavinE last edited by

                                    @cvp aahhhh ;)
                                    Okay shit but thanks for your answer

                                    When i find something i tell you

                                    1 Reply Last reply Reply Quote 0
                                    • ccc
                                      ccc last edited by ccc

                                      Wild guess but... self.subDirCustomer_Prüfungen = 'Prüfungen'.encode('utf-8')

                                      1 Reply Last reply Reply Quote 0
                                      • DavinE
                                        DavinE last edited by

                                        @ccc
                                        Now i get b'Pr\xc3\xbcfungen' as folder Name

                                        1 Reply Last reply Reply Quote 0
                                        • cvp
                                          cvp @DavinE last edited by cvp

                                          @DavinE said:

                                          How can i tell mkd to use the utf-8....

                                          Sorry, my answer guess that you still speak about smb. I just see now that your post uses mkd, thus ftp, sorry.
                                          I remember an old post here where the problem has been solved with

                                          ftp.encoding = "utf-8"
                                          

                                          Then, I can't help more.

                                          1 Reply Last reply Reply Quote 0
                                          • DavinE
                                            DavinE last edited by

                                            @cvp
                                            No Problem

                                            I find my Solution.
                                            I removed the encoding = ‚utf-8‘ and it works

                                            cvp 1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post
                                            Powered by NodeBB Forums | Contributors