예제 #1
0
    def ssh_worker(self):
        
        opts={
            'port' : int(self.profile['port_menu']),
            'user' : self.profile['user'],
            'host' : self.profile['address'],
            'private_key' : self.profile['ssh_key_path']
        }
        
        ln_filter=Tail.get_log_filter('groups',min_date=None)
        
        c = _ssh.Client(**opts)
        
        c.connect()
        c.list()
        while self.running == True:
            time.sleep(1) 
            for line in c.new_lines():

                m = ln_filter(line)
                if not m:
                    continue
                                
                dest_path = None
                src_path = None
                event = None

                if len(m) >=4:
                    src_path = base64.standard_b64decode(m[3])
                    src_path = os.path.join(self.profile['local_root'],src_path)
                    event =FileSystemEvent(m[2], src_path ,True)

                if len(m) >=5 and not m[4] is None:
                    dest_path = base64.standard_b64decode(m[3])
                    dest_path = os.path.join(self.profile['local_root'],dest_path)
                    event =FileSystemMovedEvent(src_path, dest_path ,True)
                


                if not event is None: 
                    self.cmd_create(event)
        self.log.info( 'ssh_worker shutting down' )
        if c.running:
            c.close()
예제 #2
0
 def test_behavior_readonly_public_attributes(self):
     event = FileSystemMovedEvent(path_2, path_1, True)
     assert_readonly_public_attributes(event)
예제 #3
0
 def test_dest_path(self):
     event = FileSystemMovedEvent(path_1, path_2, True)
     assert_equal(path_2, event.dest_path)
예제 #4
0
 def test___repr__(self):
     event = FileSystemMovedEvent(path_1, path_2, True)
     assert_equal('<FileSystemMovedEvent: src_path=%s, dest_path=%s, is_directory=%s>' \
                  % (path_1, path_2, True), event.__repr__())
예제 #5
0
 def test___init__(self):
     event = FileSystemMovedEvent(path_1, path_2, True)
     assert_equal(event.src_path, path_1)
     assert_equal(event.dest_path, path_2)
     assert_equal(event.event_type, EVENT_TYPE_MOVED)
     assert_equal(event.is_directory, True)
예제 #6
0
 def test___repr__(self):
   event = FileSystemMovedEvent(path_1, path_2, True)
   self.assertEqual(
     '<FileSystemMovedEvent: src_path=%s, dest_path=%s, '\
     'is_directory=%s>' % (path_1, path_2, True), event.__repr__())
예제 #7
0
 def test_file_moved(self):
     with patch('subprocess.Popen') as mock:
         instance = mock.return_value
         instance.communicate.return_value = ('output', TEST_RESULTS_OK)
         event = FileSystemMovedEvent(self.src_path, self.dest_path, False)
         self._run_event(event)
예제 #8
0
 def test_behavior_readonly_public_attributes(self):
     event = FileSystemMovedEvent(path_2, path_1, True)
     for prop in list_attributes(event):
         self.assertRaises(AttributeError, setattr, event, prop, None)