def test_url(self): # test http urlstr = "http://test.url.com" self.assertEqual(deserialize.url(urlstr), urlstr) # test https urlstr = "https://test.url.com" self.assertEqual(deserialize.url(urlstr), urlstr) # test ip urlstr = "https://127.0.0.1" self.assertEqual(deserialize.url(urlstr), urlstr) # test port urlstr = "https://127.0.0.1:5000" self.assertEqual(deserialize.url(urlstr), urlstr) # test ignores case urlstr = "HTTP://TEST.URL.COM" self.assertEqual(deserialize.url(urlstr), urlstr) # test invalid def callback(): deserialize.url("--?%>=_`~$") self.assertRaises(exceptions.InvalidUrl, callback)
def __init__(self, url=common.DEFAULT_URL, debug=False, quiet=False, use_folder_tree=False, max_size=common.DEFAULT_MAX_SIZE, store_path=common.DEFAULT_STORE_PATH, config_path=common.DEFAULT_CONFIG_PATH, connection_retry_limit=common.DEFAULT_CONNECTION_RETRY_LIMIT, connection_retry_delay=common.DEFAULT_CONNECTION_RETRY_DELAY): debug = deserialize.flag(debug) quiet = deserialize.flag(quiet) self.url = deserialize.url(url) self.use_folder_tree = deserialize.flag(use_folder_tree) self.max_size = deserialize.byte_count(max_size) self.messenger = None # lazy self.btctxstore = BtcTxStore() self.retry_limit = deserialize.positive_integer(connection_retry_limit) self.retry_delay = deserialize.positive_integer(connection_retry_delay) # paths self.cfg_path = os.path.realpath(config_path) control.util.ensure_path_exists(os.path.dirname(self.cfg_path)) self.store_path = os.path.realpath(store_path) control.util.ensure_path_exists(self.store_path) # check for vfat partions fstype = control.util.get_fs_type(self.store_path) if fstype == "vfat": logger.info("Detected vfat partition, using folder tree.") self.use_folder_tree = True if fstype is None: msg = "Couldn't detected partition type for '{0}'" logger.warning(msg.format(self.store_path)) self.cfg = control.config.get(self.btctxstore, self.cfg_path)
def __init__(self, url=common.DEFAULT_URL, debug=False, quiet=False, use_folder_tree=False, max_size=common.DEFAULT_MAX_SIZE, store_path=common.DEFAULT_STORE_PATH, config_path=common.DEFAULT_CONFIG_PATH, connection_retry_limit=common.DEFAULT_CONNECTION_RETRY_LIMIT, connection_retry_delay=common.DEFAULT_CONNECTION_RETRY_DELAY): debug = deserialize.flag(debug) quiet = deserialize.flag(quiet) self.url = deserialize.url(url) self.use_folder_tree = deserialize.flag(use_folder_tree) self.max_size = deserialize.byte_count(max_size) self.messenger = None # lazy self.btctxstore = BtcTxStore() self.retry_limit = deserialize.positive_integer(connection_retry_limit) self.retry_delay = deserialize.positive_integer(connection_retry_delay) # paths self.cfg_path = os.path.realpath(config_path) control.util.ensure_path_exists(os.path.dirname(self.cfg_path)) self.store_path = os.path.realpath(store_path) control.util.ensure_path_exists(self.store_path) # check for vfat partions if control.util.get_fs_type(self.store_path) == "vfat": self.use_folder_tree = True self.cfg = control.config.get(self.btctxstore, self.cfg_path)
def __init__(self, url=common.DEFAULT_URL, debug=False, quiet=False, use_folder_tree=False, max_size=common.DEFAULT_MAX_SIZE, min_free_size=common.DEFAULT_MIN_FREE_SIZE, store_path=common.DEFAULT_STORE_PATH, config_path=common.DEFAULT_CONFIG_PATH, connection_retry_limit=common.DEFAULT_CONNECTION_RETRY_LIMIT, connection_retry_delay=common.DEFAULT_CONNECTION_RETRY_DELAY, nop2p=True): debug = deserialize.flag(debug) quiet = deserialize.flag(quiet) self.storjnode = None self.nop2p = nop2p self.url = deserialize.url(url) self.use_folder_tree = deserialize.flag(use_folder_tree) self.max_size = deserialize.byte_count(max_size) self.min_free_size = deserialize.byte_count(min_free_size) self.messenger = None # lazy self.btctxstore = BtcTxStore() self.retry_limit = deserialize.positive_integer(connection_retry_limit) self.retry_delay = deserialize.positive_integer(connection_retry_delay) # paths self.cfg_path = os.path.realpath(config_path) storjnode.util.ensure_path_exists(os.path.dirname(self.cfg_path)) self.store_path = os.path.realpath(store_path) storjnode.util.ensure_path_exists(self.store_path) # check for vfat partions try: fstype = storjnode.util.get_fs_type(self.store_path) # FileNotFoundError: [Errno 2] No such file or directory: '/etc/mtab' # psutil: https://code.google.com/p/psutil/issues/detail?id=434 except EnvironmentError as e: logger.warning(e) fstype = None if fstype == "vfat": logger.info("Detected vfat partition, using folder tree.") self.use_folder_tree = True if fstype is None: msg = "Couldn't detected partition type for '{0}'" logger.warning(msg.format(self.store_path)) self.cfg = storjnode.config.get(self.btctxstore, self.cfg_path)
def callback(): deserialize.url("--?%>=_`~$")