예제 #1
0
 def on_moved(self, event):
     isdir = isinstance(event, DirMovedEvent)
     abs_src_src_path = os.path.abspath(event.src_path)
     abs_src_dst_path = os.path.abspath(event.dest_path)
     src_ignore_tag, dst_ignore_tag = (self.is_ignore(
         abs_src_src_path, isdir), self.is_ignore(abs_src_dst_path, isdir))
     relative_src_path = self.get_relative_src_path(event.src_path)
     relative_dst_path = self.get_relative_src_path(event.dest_path)
     dst_src_path = os.path.join(self.dst_path, relative_src_path)
     dst_dst_path = os.path.join(self.dst_path, relative_dst_path)
     if src_ignore_tag and dst_ignore_tag:
         return
     elif dst_ignore_tag:
         remote_rm(dst_ssh=self.dst_ssh, dst_path=dst_src_path)
         logger.info("Remove {} remotely".format(dst_src_path))
     elif src_ignore_tag:
         dst_folder_path = dst_dst_path[:-len(dst_dst_path.split("/")[-1])]
         remote_create_folder(dst_ssh=self.dst_ssh,
                              dst_path=dst_folder_path)
         rsync(dst_ssh=self.dst_ssh,
               src_path=abs_src_dst_path,
               dst_path=dst_dst_path)
         logger.info("Rsync {} remotely".format(dst_dst_path))
     else:
         remote_mv(dst_ssh=self.dst_ssh,
                   src_path=dst_src_path,
                   dst_path=dst_dst_path)
         logger.info("Move {} to {} remotely".format(
             dst_src_path, dst_dst_path))
     logger.info("Because of move method, try to update all ignore pattern")
     self.init_gitignore(self.src_path)
예제 #2
0
 def on_moved(self, event):
     isdir = isinstance(event, DirMovedEvent)
     abs_src_src_path = os.path.abspath(event.src_path)
     abs_src_dst_path = os.path.abspath(event.dest_path)
     src_ignore_tag, dst_ignore_tag = (
         self.is_ignore(abs_src_src_path, isdir),
         self.is_ignore(abs_src_dst_path, isdir)
     )
     relative_src_path = self.get_relative_src_path(event.src_path)
     relative_dst_path = self.get_relative_src_path(event.dest_path)
     dst_src_path = os.path.join(self.dst_path, relative_src_path)
     dst_dst_path = os.path.join(self.dst_path, relative_dst_path)
     if src_ignore_tag and dst_ignore_tag:
         return
     elif dst_ignore_tag:
         remote_rm(dst_ssh=self.dst_ssh, dst_path=dst_src_path)
         logger.info("Remove {} remotely".format(dst_src_path))
     elif src_ignore_tag:
         dst_folder_path = dst_dst_path[:-len(dst_dst_path.split("/")[-1])]
         remote_create_folder(dst_ssh=self.dst_ssh,
                              dst_path=dst_folder_path)
         rsync(dst_ssh=self.dst_ssh, src_path=abs_src_dst_path,
               dst_path=dst_dst_path)
         logger.info("Rsync {} remotely".format(dst_dst_path))
     else:
         remote_mv(dst_ssh=self.dst_ssh, src_path=dst_src_path,
                   dst_path=dst_dst_path)
         logger.info("Move {} to {} remotely".format(
             dst_src_path, dst_dst_path
         ))
     logger.info("Because of move method, try to update all ignore pattern")
     self.init_gitignore(self.src_path)
예제 #3
0
 def test_remote_mv(self, _os):
     _os.popen.return_value = True
     remote_mv("user@host", "/a/b.py", "/c.py")
     _os.popen.assert_called_once_with("ssh user@host \"mv /a/b.py /c.py\"")
예제 #4
0
 def test_remote_mv(self, _os):
     _os.popen.return_value = True
     remote_mv("user@host", "/a/b.py", "/c.py")
     _os.popen.assert_called_once_with("ssh user@host \"mv /a/b.py /c.py\"")