示例#1
0
    def test_get_uuid(self, open, isfile):
        isfile.return_value = True

        f = io.StringIO('test_uuid')
        open.return_value = f

        my_uuid = syncall.get_uuid('file_test')

        open.assert_called_with("file_test", "r")
        self.assertEqual('test_uuid', my_uuid)
示例#2
0
    def test_get_uuid(self, open, isfile):
        isfile.return_value = True

        f = io.StringIO('test_uuid')
        open.return_value = f

        my_uuid = syncall.get_uuid('file_test')

        open.assert_called_with("file_test", "r")
        self.assertEqual('test_uuid', my_uuid)
示例#3
0
    def test_get_generate_uuid(self, gen, isfile):
        gen.return_value = "1234"
        isfile.return_value = False

        self.assertEqual(syncall.get_uuid('file_test'), "1234")
示例#4
0
# Add custom logging for console
def log_console(self, message, *args, **kws):
    if self.isEnabledFor(LEVEL_CONSOLE_LOG):
        self._log(LEVEL_CONSOLE_LOG, message, args, **kws)
logging.Logger.console = log_console

# End logging config

CONFIG_DIR = os.environ['HOME'] + '/.syncall'
SHARE_DIR = CONFIG_DIR + '/shared/'

os.makedirs(CONFIG_DIR, exist_ok=True)
os.makedirs(SHARE_DIR, exist_ok=True)

uuid = syncall.get_uuid(CONFIG_DIR + '/.uuid')

share_dir_obj = syncall.Directory(uuid, SHARE_DIR,
                                  create_temp_dir=True)
share_dir_obj.update_index()

network_discovery = syncall.NetworkDiscovery(
    syncall.DEFAULT_PORT,
    syncall.VERSION,
    uuid
)
network_discovery.start_listening()

connection_listener = syncall.ConnectionListener(
    uuid,
    syncall.DEFAULT_PORT
示例#5
0
def log_console(self, message, *args, **kws):
    if self.isEnabledFor(LEVEL_CONSOLE_LOG):
        self._log(LEVEL_CONSOLE_LOG, message, args, **kws)


logging.Logger.console = log_console

# End logging config

CONFIG_DIR = os.environ['HOME'] + '/.syncall'
SHARE_DIR = CONFIG_DIR + '/shared/'

os.makedirs(CONFIG_DIR, exist_ok=True)
os.makedirs(SHARE_DIR, exist_ok=True)

uuid = syncall.get_uuid(CONFIG_DIR + '/.uuid')

share_dir_obj = syncall.Directory(uuid, SHARE_DIR, create_temp_dir=True)
share_dir_obj.update_index()

network_discovery = syncall.NetworkDiscovery(syncall.DEFAULT_PORT,
                                             syncall.VERSION, uuid)
network_discovery.start_listening()

connection_listener = syncall.ConnectionListener(uuid, syncall.DEFAULT_PORT)
transfer_listener = syncall.ConnectionListener(uuid,
                                               syncall.DEFAULT_TRANSFER_PORT)

store_manager = syncall.RemoteStoreManager(network_discovery,
                                           connection_listener,
                                           transfer_listener, share_dir_obj,
示例#6
0
    def test_get_generate_uuid(self, gen, isfile):
        gen.return_value = "1234"
        isfile.return_value = False

        self.assertEqual(syncall.get_uuid('file_test'), "1234")