示例#1
0
def startTransfer():
  global users
  global transfers
  getUsers()
  User.printUsers(users)
  username = raw_input("From which user?").rstrip('\n')
  user = User.findUser(users, username)
  File.printFiles(user.files)
  filename = raw_input("Which file?").rstrip('\n')
  file = File.findFile(user.files, filename)
  transfer = Transfer(user, file)
  transfers.append(transfer)
  transfer.start()
示例#2
0
def comm():
  global users
  while True:
    inp = raw_input("Enter desired command:\n")
    inp = inp.rstrip('\n')
    if inp == "users":
      users = getUsers()
      User.printUsers(users)
    elif inp == "files":
      username = raw_input("Enter username:"******"discn":
      discn()
      return
    elif inp == "updat":
      updateFiles()
    elif inp == "transfer":
      startTransfer()
    else:
      print "Dafuq is this m8?"
示例#3
0
    server_closer = ServerInitializer(1,o_server=p2pserver)
    server_closer.start()
    server_closer.join()
  except AttributeError:
    pass
  sys.exit(0)

if __name__ == "__main__":

  if len(sys.argv) != 7:
    print "Usage: " + sys.argv[0] + " <server-ip> <user> <pass> <dir> <dest-dir> <local-port>"
    sys.exit(1)

  signal.signal(signal.SIGINT, signal_handler)

  s = connect(sys.argv[1])

  if not auth(sys.argv[2], sys.argv[3], sys.argv[6]):
    print "Authentication failed..."
    sys.exit(0)

  user_files = File.getFileStruct(None, sys.argv[4])
  File.printFiles(user_files)
  
  s.sendall(pickle.dumps(user_files,-1))

  dest_dir = sys.argv[5]
  server_init = ServerInitializer(0, int(sys.argv[6]))
  server_init.start()
  comm()