Beispiel #1
0
 def _music_sites(self):
     " List, Remove, Update music sites "
     if len(self.config["local_music"].get_dir_list()) < 1:
         Message.err("You must have at least one local dir to move music.")
         return False
     while True:
         action, index = Menu.display_sites(self.config["sites"])
         if action == "q":
             return
         if action == "n":
             code, data = Input.site_data()
             if not code:
                 continue
             site = RemoteSite(data["name"], data["username"], data["hostname"], data["port"])
             self.config["sites"].append(site)
             continue
             # existing site actions
         if index < 1:
             Message.err("You must specify a site to perform the action on.")
             continue
         index -= 1
         remote_site = self.config["sites"][index]
         if action == "d":
             if Input.confirm_delete():
                 self.config["sites"].pop(index)
         elif action == "l":
             self._remote_dirs(remote_site)
         elif action == "b":
             self._remote_blocks(remote_site)
         elif action == "m":
             if len(remote_site.get_dir_list()) < 1:
                 Message.err("Remote sites must have at least 1 dir to move music.")
                 continue
             self._move_music(remote_site)
Beispiel #2
0
 def _remote_dirs(self, remote_site):
     " List remote directories, and delete "
     while True:
         action, index = Menu.display_remote_list(remote_site.get_dir_list())
         if action == "q":
             return
         if action == "d":
             if Input.confirm_delete():
                 remote_site.del_dir(index - 1)
             continue
         if action == "a":
             dir = Input.prompt_add_remote_dir()
             remote_site.add_dir(dir)
Beispiel #3
0
 def _update_local(self):
     " Update local directories. "
     while True:
         action, index = Menu.display_list(
             self.config["local_music"].get_dir_list(), self.config["local_music"]._active_save_dir + 1
         )
         if action == "s":
             self.config["local_music"].set_save_dir(index - 1)
         elif action == "d":
             if Input.confirm_delete():
                 self.config["local_music"].del_dir(index - 1)
         elif action == "a":
             dir = Input.prompt_add_dir()
             if dir:
                 self.config["local_music"].add_dir(dir)
         else:
             return
Beispiel #4
0
 def connect(self):
     " connect to the host "
     # ssh
     ssh_client = paramiko.SSHClient()
     ssh_client.load_system_host_keys()
     try:
         ssh_client.connect(
             self.remote_site.hostname, self.remote_site.port, self.remote_site.username, self.password
         )
     except SSHException, err:
         if self.password:
             raise SSHException("Password authentication failed: %s" % (err))
         Message.err("Connect failed: %s" % (err))
         self.password = Input.prompt_pass()
         self.connect()