Advertisement
Guest User

Untitled

a guest
Dec 12th, 2017
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.90 KB | None | 0 0
  1. import paramiko
  2. import os
  3. import time
  4.  
  5. def fullLine():
  6. print(" #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#")
  7. def emptyLine():
  8. print(" # #")
  9. def titleLine(title):
  10. l=len(title)
  11. print(" # "+title+" "*(72-l)+"#")
  12. #file = open('debug.txt','r+')
  13. #paramiko.util.log_to_file('debug.txt',level='DEBUG')
  14.  
  15. # TRANSPORT
  16. host = 'tityos.feralhosting.com'
  17. port = 22
  18. user = 'iroh'
  19. tp = paramiko.Transport(host,port)
  20.  
  21. # KEY AND CONNECT
  22. key = paramiko.RSAKey.from_private_key_file('.ssh/feral',password='')
  23. tp.connect(username = user, pkey = key)
  24.  
  25. # SFTP GOOO
  26. sftp = paramiko.SFTPClient.from_transport(tp)
  27. sftp.chdir("private/rtorrent/data")
  28. dataDir = sftp.listdir_attr()
  29. sftp.chdir("../pBay")
  30. pBayDir = sftp.listdir_attr()
  31. sftp.chdir("../music")
  32. musicDir = sftp.listdir_attr()
  33. dataDict = {}
  34. pBayDict = {}
  35. musicDict = {}
  36. for item in dataDir:
  37. dataDict[item.filename]=item.st_mtime
  38. for item in pBayDir:
  39. pBayDict[item.filename]=item.st_mtime
  40. for item in musicDir:
  41. musicDict[item.filename]=item.st_mtime
  42.  
  43. sftp.close()
  44. tp.close()
  45. dataLocalDir = os.listdir(os.path.expanduser("../../Volumes/D/Backups"))
  46. pBayLocalDir = os.listdir(os.path.expanduser("../../Volumes/D/pBay"))
  47. musicLocalDir = os.listdir(os.path.expanduser("../../Volumes/D/music"))
  48. dataUnpaired = []
  49. pBayUnpaired = []
  50. musicUnpaired = []
  51. for item in dataDir:
  52. if item.filename in dataLocalDir:
  53. pass
  54. else:
  55. dataUnpaired.append(item.filename)
  56. for item in pBayDir:
  57. if item.filename in pBayLocalDir:
  58. pass
  59. else:
  60. pBayUnpaired.append(item.filename)
  61. for item in musicDir:
  62. if item.filename in musicLocalDir:
  63. pass
  64. else:
  65. musicUnpaired.append(item.filename)
  66. sDataUnpaired = sorted(dataUnpaired,key=lambda fname: dataDict[fname])
  67. sPBayUnpaired = sorted(pBayUnpaired,key=lambda fname: pBayDict[fname])
  68. sMusicUnpaired = sorted(musicUnpaired,key=lambda fname: musicDict[fname])
  69.  
  70.  
  71.  
  72. fullLine()
  73. emptyLine()
  74. titleLine("DATA DIRECTORY")
  75. emptyLine()
  76. for item in sDataUnpaired:
  77. l=len(item)
  78. print(" # "+item[0:45]+" "*(45-l)+" |"+ " "+str(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(dataDict[item])))+" #")
  79. emptyLine()
  80. fullLine()
  81. emptyLine()
  82. titleLine("pBaY DIRECTORY")
  83. emptyLine()
  84. for item in sPBayUnpaired:
  85. l=len(item)
  86. print(" # "+item[0:45]+" "*(45-l)+" |"+ " "+str(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(pBayDict[item])))+" #")
  87. emptyLine()
  88. fullLine()
  89. emptyLine()
  90. titleLine("Music DIRECTORY")
  91. emptyLine()
  92.  
  93. for item in sMusicUnpaired:
  94. l=len(item)
  95. print(" # "+item[0:45]+" "*(45-l)+" |"+ " "+str(time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(musicDict[item])))+" #")
  96. print(" # #")
  97. fullLine()
  98.  
  99. print("")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement