Exemple #1
0
 def __init__(self, latest_patch_version, tahoe_node_url, verbosity=0):
     self.verbosity = verbosity
     self.tahoe_node_url = tahoe_node_url
     ver = get_tahoe_version(tahoe_node_url)
     if ver is not None:
         self.tahoe_version = LooseVersion(ver)
     else:
         self.tahoe_version = ver
     print("Detected tahoe v%s" % self.tahoe_version)
     self.latest_patch_version = latest_patch_version
     self.datadir = find_datadir()
     self.is_compatible_version = compatible_version(self.tahoe_version,
             self.verbosity)
     if self.verbosity > 0 and ver is not None:
         print("-- Patching or checking Tahoe web console --")
     tahoe_dir = find_tahoe_dir(tahoe_node_url)
     if tahoe_dir is not None:
         self.webdir = os.path.join(tahoe_dir, 'web')
     else:
         sys.exit(1)
     self.filepaths = {'welcome.xhtml': [], 'tahoe.css': []}
     if ver is not None:
         self.add_patch_filepaths()
         self.add_target_filepaths()
     if self.verbosity > 3:
         print('DEBUG: Data dir is: %s' % self.datadir)
         print('DEBUG: Tahoe web dir is: %s' % self.webdir)
         if ver is not None and self.is_compatible_version:
             print('DEBUG: File paths:')
             print(self.filepaths)
Exemple #2
0
 def __init__(self, latest_patch_version, tahoe_node_url, verbosity=0):
     self.verbosity = verbosity
     self.tahoe_node_url = tahoe_node_url
     ver = get_tahoe_version(tahoe_node_url)
     if ver is not None:
         self.tahoe_version = LooseVersion(ver)
     else:
         self.tahoe_version = ver
     print("Detected tahoe v%s" % self.tahoe_version)
     self.latest_patch_version = latest_patch_version
     self.datadir = find_datadir()
     self.is_compatible_version = compatible_version(
         self.tahoe_version, self.verbosity)
     if self.verbosity > 0 and ver is not None:
         print("-- Patching or checking Tahoe web console --")
     tahoe_dir = find_tahoe_dir(tahoe_node_url)
     if tahoe_dir is not None:
         self.webdir = os.path.join(tahoe_dir, 'web')
     else:
         sys.exit(1)
     self.filepaths = {'welcome.xhtml': [], 'tahoe.css': []}
     if ver is not None:
         self.add_patch_filepaths()
         self.add_target_filepaths()
     if self.verbosity > 3:
         print('DEBUG: Data dir is: %s' % self.datadir)
         print('DEBUG: Tahoe web dir is: %s' % self.webdir)
         if ver is not None and self.is_compatible_version:
             print('DEBUG: File paths:')
             print(self.filepaths)
Exemple #3
0
 def __init__(self, verbosity=0):
     self.verbosity = verbosity
     self.tempdir = tempfile.mkdtemp()
     if self.verbosity > 2:
         print('DEBUG: tempdir is: %s' % self.tempdir)
     # check for pandoc and markdown
     # find template locations
     self.datadir = find_datadir()
Exemple #4
0
 def __init__(self, verbosity=0):
     self.verbosity = verbosity
     self.tempdir = tempfile.mkdtemp()
     if self.verbosity > 2:
         print('DEBUG: tempdir is: %s' % self.tempdir)
     # check for pandoc and markdown
     # find template locations
     self.datadir = find_datadir()
Exemple #5
0
def parse_args(argv):
    """Parse options given on the command line."""

    default_config = parse_config_files(argv)

    # 3. Argparse
    # defaults to values from Configparser
    parser = argparse.ArgumentParser()
    # actions
    action_opts = parser.add_argument_group(
        'Actions', 'These arguments control which actions will be executed.')
    action_opts.add_argument('-s', '--sync-introducers',
            action = 'store_true',
            dest = "sync",
            default = False,
            help = "Synchronize the local list of introducers with the "
                    "subscription's.")
    action_opts.add_argument('-m', '--merge-introducers',
            action = 'store_true',
            dest = "merge",
            default = False,
            help = 'Downloads and merges list of introducers into your '
                    'local list.')
    action_opts.add_argument('-n', '--download-news',
            action = 'store_true',
            dest = "news",
            default = False,
            help = 'Downloads news feed.')
    action_opts.add_argument('-r', '--repair',
            action = 'store_true',
            dest = "repair",
            default = False,
            help = 'Retrieve a list of shares and maintain/repair them. '
                    'Repairs I2P community shares by default.')
    action_opts.add_argument('--check-version', '--check-update',
            action = 'store_true',
            dest = "check_version",
            default = False,
            help = 'Check for a new version of grid-updates.')
    action_opts.add_argument('--download-update', '--update',
            action = 'store_true',
            dest = "download_update",
            default = False,
            help = 'Download a new version of grid-updates.')
    action_opts.add_argument('--patch-tahoe',
            action = 'store_true',
            dest = "patch_ui",
            default = False,
            help = ('Patch the Tahoe Web UI to display grid-updates news '
                                                'in an IFrame.'))
    action_opts.add_argument('--undo-patch-tahoe',
            action = 'store_true',
            dest = "undo_patch_ui",
            default = False,
            help = 'Restore the original Tahoe Web console files.')
    action_opts.add_argument('--make-news',
            action = 'store',
            dest = "news_source_file",
            help = 'Compile a grid-updates-compatible NEWS.tgz file from'
                    ' a Markdown file.')
    parser.add_argument_group(action_opts)
    # options
    other_opts = parser.add_argument_group(
        'Options', 'These arguments can override various settings.')
    other_opts.add_argument('-d', '--node-directory',
            action = 'store',
            dest = "tahoe_node_dir",
            default = default_config['tahoe_node_dir'],
            help = 'Specify the Tahoe node directory.')
    other_opts.add_argument('-u', '--node-url',
            action = 'store',
            dest = 'tahoe_node_url',
            help = "Specify the Tahoe gateway node's URL.")
    other_opts.add_argument('--list-uri',
            action = 'store',
            dest = 'list_uri',
            default = default_config['list_uri'],
            help = 'Override default location of introducers list.')
    other_opts.add_argument('--news-uri',
            action = 'store',
            dest = 'news_uri',
            default = default_config['news_uri'],
            help = 'Override default location of news list.')
    other_opts.add_argument('--script-uri',
            action = 'store',
            dest = 'script_uri',
            default = default_config['script_uri'],
            help = 'Override default location of script releases.')
    other_opts.add_argument('--repairlist-uri',
            action = 'store',
            dest = 'repairlist_uri',
            default = default_config['repairlist_uri'],
            help = ('Override default location of additional repair '
                    'subscription.'))
    other_opts.add_argument('--format',
            action = 'store',
            dest = 'update_format',
            default = 'tar',
            help = ('Specify in which format to download the update.'))
    other_opts.add_argument('-o', '--output-dir',
            action = 'store',
            dest = 'output_dir',
            default = default_config['output_dir'],
            help = ('Override default output directory (%s) for script '
                    'update downloads and NEWS.tgz generation.'
                    % os.getcwd()))
    parser.add_argument_group(other_opts)
    # remaining
    parser.add_argument('-v',
            action='count',
            dest='verbosity',
            default=1,
            help = 'Increase verbosity (-vv for debug mode).')
    parser.add_argument('-q',
            action='store_const',
            const=0,
            dest='verbosity',
            help = 'Turn off verbosity.')
    parser.add_argument('-V', '--version',
            dest = "version",
            action = "store_true",
            default = False,
            help = 'Display version information.')
    # Fake option: this option will not be accessed directly; --config is used
    # for ConfigParser (see above); this entry exists here for completeness of
    # --help
    parser.add_argument('-c', '--config',
            action = 'store',
            dest = 'config',
            help = 'Manually specify a configuration file.')
    # parse arguments
    opts = parser.parse_args()

    # DEBUG
    if opts.verbosity > 2:
        print('DEBUG: The following options have been set:')
        for opt in [
                'tahoe_node_dir',
                'tahoe_node_url',
                'list_uri',
                'news_uri',
                'script_uri',
                'repairlist_uri',
                'output_dir']:
            print('%16s: %s' % (opt, vars(opts)[opt]))
        print("DEBUG: Patch directory is:", find_datadir())

    return opts