コード例 #1
0
ファイル: myapp.py プロジェクト: RedOrion/MontyLacuna
 def login(self):
     """ Logs in to TLE using the credentials stored in our currently-set 
     config file and section.
     """
     client_getter = GetClient(self, self.config_file, self.config_section)
     self.client = client_getter.request()
     self.is_logged_in = True
     self.abbrv = Abbreviations(self.client, vardir = self.instdir + "/var")
コード例 #2
0
 def __init__(self):
     self.version = '0.1'
     parser = argparse.ArgumentParser(
         description="Deletes the abbrevation for a full body name.",
         epilog=
         "Full docs can be found at http://tmtowtdi.github.io/MontyLacuna/scripts/abbrv.html",
     )
     parser.add_argument(
         'name',
         metavar='<body>',
         action='store',
         help=
         "The full name of the body to abbreviate or check on.  Use 'all' if you're showing abbreviations and want to see them all."
     )
     super().__init__(parser)
     self.abbrv = Abbreviations(self.client)
コード例 #3
0
ファイル: libbin.py プロジェクト: RedOrion/MontyLacuna
    def __init__(self, parser, section: str = 'sitter', testargs: dict = {}):
        self.bindir = os.path.abspath(os.path.dirname(sys.argv[0]))

        if not hasattr(self, 'guest') or not self.guest:
            parser.add_argument(
                '--file',
                dest='config_file',
                metavar='<config_file>',
                action=FindConfigFileAction,
                default=self.bindir + "/../etc/lacuna.cfg",
                help=
                "Path to the config file.  Defaults to 'ROOT/etc/lacuna.cfg'")
            parser.add_argument('--section',
                                dest='config_section',
                                metavar='<section>',
                                action='store',
                                default=section,
                                help="Config file section.  Defaults to '" +
                                section + "'.")

        parser.add_argument(
            '-q',
            '--quiet',
            dest='quiet',
            action='store_true',
            help=
            "By default, information on what's happening gets displayed to the screen.  Including this will silence all output.  Overrides '-v'."
        )

        parser.add_argument(
            '-v',
            '--verbose',
            dest='verbose',
            action='count',
            help=
            "Increase output verbosity level -- produces more in-depth screen reporting on what's happening.  Has no effect if --quiet is used."
        )

        if not hasattr(self, 'skip_argparse'):
            self.skip_argparse = {}
        for i in sys.argv:
            if i in self.skip_argparse:
                print("Skipping argparse because of existence of ", i)
                self.skip_argparse[i]()

        if testargs:
            ### testargs dict was passed in to impersonate command-line args;
            ### we're most likely running a unit test.  Accept that dict and
            ### don't involve Argparse.
            testargs['quiet'] = True
            testargs['verbose'] = 0
            self.set_testargs(testargs)
        else:
            self.args = parser.parse_args()
            self.connect()

        ### The update script uses a Guest client, not a Member client, and a
        ### Guest client can't have abbreviations.
        if isinstance(self.client, lacuna.clients.Member):
            self.abbrv = Abbreviations(self.client)

        ### Set log level
        if not self.args.quiet:
            if self.args.verbose:
                self.client.user_log_stream_handler.setLevel('DEBUG')
            else:
                self.client.user_log_stream_handler.setLevel('INFO')

        ### Set version
        vers = '0.1'
        if hasattr(self, 'version'):
            vers = self.version
        else:
            self.version = vers
        parser.add_argument('--version',
                            action='version',
                            version=os.path.basename(sys.argv[0]) + ' ' + vers,
                            help="Print program version and quit")