Example #1
0
 def initialize(self, args):
     try:
         self.is_verbose = args.verbose
         self.is_dryrun = args.dry_run
         self.title = args.title
         # validate channel names
         validate_channel(args.uplift_to)
         validate_channel(args.start_from)
         # read github token FIRST from CLI, then from .npmrc
         self.github_token = get_env_var('GITHUB_TOKEN')
         if len(self.github_token) == 0:
             try:
                 result = execute(['npm', 'config', 'get', 'BRAVE_GITHUB_TOKEN']).strip()
                 if result == 'undefined':
                     raise Exception('`BRAVE_GITHUB_TOKEN` value not found!')
                 self.github_token = result
             except Exception as e:
                 print('[ERROR] no valid GitHub token was found either in npmrc or ' +
                       'via environment variables (BRAVE_GITHUB_TOKEN)')
                 return 1
         # if `--owners` is not provided, fall back to user owning token
         self.parsed_owners = parse_user_logins(self.github_token, args.owners, verbose=self.is_verbose)
         if len(self.parsed_owners) == 0:
             self.parsed_owners = [get_authenticated_user_login(self.github_token)]
         self.labels = parse_labels(self.github_token, BRAVE_CORE_REPO, args.labels, verbose=self.is_verbose)
         if self.is_verbose:
             print('[INFO] config: ' + str(vars(self)))
         return 0
     except Exception as e:
         print('[ERROR] error returned from GitHub API while initializing config: ' + str(e))
         return 1
Example #2
0
 def initialize(self, args):
     try:
         self.is_verbose = args.verbose
         self.is_dryrun = args.dry_run
         self.title = args.title
         # validate channel names
         validate_channel(args.uplift_to)
         validate_channel(args.start_from)
         # read github token FIRST from CLI, then from .npmrc
         self.github_token = get_env_var('GITHUB_TOKEN')
         if len(self.github_token) == 0:
             try:
                 result = execute(['npm', 'config', 'get', 'BRAVE_GITHUB_TOKEN']).strip()
                 if result == 'undefined':
                     raise Exception('`BRAVE_GITHUB_TOKEN` value not found!')
                 self.github_token = result
             except Exception as e:
                 print('[ERROR] no valid GitHub token was found either in npmrc or ' +
                       'via environment variables (BRAVE_GITHUB_TOKEN)')
                 return 1
         # if `--owners` is not provided, fall back to user owning token
         self.parsed_owners = parse_user_logins(self.github_token, args.owners, verbose=self.is_verbose)
         if len(self.parsed_owners) == 0:
             self.parsed_owners = [get_authenticated_user_login(self.github_token)]
         self.labels = parse_labels(self.github_token, BRAVE_CORE_REPO, args.labels, verbose=self.is_verbose)
         if self.is_verbose:
             print('[INFO] config: ' + str(vars(self)))
         return 0
     except Exception as e:
         print('[ERROR] error returned from GitHub API while initializing config: ' + str(e))
         return 1