Пример #1
0
def start(args):
    """Set up the Geofront server URL."""
    for path in load_config_paths(CONFIG_RESOURCE):
        path = os.path.join(path.decode(), SERVER_CONFIG_FILENAME)
        if os.path.isfile(path):
            message = 'Geofront server URL is already configured: ' + path
            if args.force:
                print(message + '; overwriting...', file=sys.stderr)
            else:
                parser.exit(message)
    while True:
        server_url = input('Geofront server URL: ')
        if not server_url.startswith(('https://', 'http://')):
            print(server_url, 'is not a valid url.')
            continue
        elif not server_url.startswith('https://'):
            cont = input('It is not a secure URL. '
                         'https:// is preferred over http://. '
                         'Continue (y/N)? ')
            if cont.strip().lower() != 'y':
                continue
        break
    server_config_filename = os.path.join(
        save_config_path(CONFIG_RESOURCE).decode(),
        SERVER_CONFIG_FILENAME
    )
    with open(server_config_filename, 'w') as f:
        print(server_url, file=f)
    authenticate.call(args)
Пример #2
0
def start(args):
    """Set up the Geofront server URL."""
    for path in load_config_paths(CONFIG_RESOURCE):
        path = os.path.join(path.decode(), SERVER_CONFIG_FILENAME)
        if os.path.isfile(path):
            message = 'Geofront server URL is already configured: ' + path
            if args.force:
                print(message + '; overwriting...', file=sys.stderr)
            else:
                parser.exit(message)
    while True:
        server_url = input('Geofront server URL: ')
        if not server_url.startswith(('https://', 'http://')):
            print(server_url, 'is not a valid url.')
            continue
        elif not server_url.startswith('https://'):
            cont = input('It is not a secure URL. '
                         'https:// is preferred over http://. '
                         'Continue (y/N)? ')
            if cont.strip().lower() != 'y':
                continue
        break
    server_config_filename = os.path.join(
        save_config_path(CONFIG_RESOURCE).decode(), SERVER_CONFIG_FILENAME)
    with open(server_config_filename, 'w') as f:
        print(server_url, file=f)
    authenticate.call(args)
Пример #3
0
 def test_save_config_path(self):
     """The path should end with xdg_config/x (respecting the separator)."""
     self.tweak_env('XDG_CONFIG_HOME', 'config_home')
     self.patch(os, "makedirs", lambda *args: None)
     result = basedir.save_config_path("x")
     self.assertEqual(result.decode('utf-8').split(os.sep)[-2:],
                      ['config_home', 'x'])
Пример #4
0
 def test_save_config_path(self):
     """The path should end with xdg_config/x (respecting the separator)."""
     self.tweak_env('XDG_CONFIG_HOME', 'config_home')
     self.patch(os, "makedirs", lambda *args: None)
     result = basedir.save_config_path("x")
     self.assertEqual(
         result.decode('utf-8').split(os.sep)[-2:], ['config_home', 'x'])
Пример #5
0
    del new_tcp
# end of naming shenanigans

CONFIG_FILE = "syncdaemon.conf"
CONFIG_LOGS = "logging.conf"

# sections
THROTTLING = "bandwidth_throttling"
NOTIFICATIONS = "notifications"
MAIN = "__main__"

# global logger
logger = logging.getLogger("ubuntuone.SyncDaemon.config")

# get (and possibly create if don't exists) the user config file
_user_config_path = os.path.join(save_config_path("ubuntuone"), CONFIG_FILE)

# module private config instance.
# this object is the shared config
_user_config = None

path_from_unix = lambda path: path.replace("/", os.path.sep)


def home_dir_parser(value):
    """Parser for the root_dir and shares_dir options.

    Return the path using user home + value.

    """
    path = path_from_unix(value)
Пример #6
0
    TypedConfigParser = new_tcp
    del new_tcp
# end of naming shenanigans

CONFIG_FILE = 'syncdaemon.conf'
CONFIG_LOGS = 'logging.conf'

# sections
THROTTLING = 'bandwidth_throttling'
MAIN = '__main__'

# global logger
logger = logging.getLogger('ubuntuone.SyncDaemon.config')

# get (and possibly create if don't exists) the user config file
_user_config_path = os.path.join(save_config_path('ubuntuone'),
                                 CONFIG_FILE)

# module private config instance.
# this object is the shared config
_user_config = None


def path_from_unix(path):
    return path.replace('/', os.path.sep)


def home_dir_parser(value):
    """Parser for the root_dir and shares_dir options.

    Return the path using user home + value.