Projects STRLCPY got-your-back Commits 146be40a
🤬
Revision indexing in progress... (symbol navigation in revisions will be accurate after indexed)
  • ■ ■ ■ ■ ■ ■
    gyb.py
    skipped 366 lines
    367 367   "groupsmigration": QuotaBucket(10, 1, 10),
    368 368  }
    369 369   
    370  -def getConfigPath():
    371  - return options.config_folder
    372  - 
    373 370  def getProgPath():
    374 371   if os.environ.get('STATICX_PROG_PATH', False):
    375 372   # StaticX static executable
    skipped 29 lines
    405 402   
    406 403  def getOauth2TxtStorageCredentials():
    407 404   auth_as = options.use_admin if options.use_admin else options.email
    408  - cfgFile = os.path.join(getConfigPath(), '%s.cfg' % auth_as)
     405 + cfgFile = os.path.join(options.config_folder, '%s.cfg' % auth_as)
    409 406   oauth_string = readFile(cfgFile, continueOnError=True, displayError=False)
    410 407   if not oauth_string:
    411 408   return
    skipped 15 lines
    427 424  %s --action create-project --email %s
    428 425   
    429 426  """ % (sys.argv[0], options.email)
    430  - filename = os.path.join(getConfigPath(), 'client_secrets.json')
     427 + filename = os.path.join(options.config_folder, 'client_secrets.json')
    431 428   cs_data = readFile(filename, continueOnError=True, displayError=True)
    432 429   if not cs_data:
    433 430   systemErrorExit(14, MISSING_CLIENT_SECRETS_MESSAGE)
    skipped 81 lines
    515 512   
    516 513  def writeCredentials(creds):
    517 514   auth_as = options.use_admin if options.use_admin else options.email
    518  - cfgFile = os.path.join(getConfigPath(), '%s.cfg' % auth_as)
     515 + cfgFile = os.path.join(options.config_folder, '%s.cfg' % auth_as)
    519 516   creds_data = {
    520 517   'token': creds.token,
    521 518   'refresh_token': creds.refresh_token,
    skipped 52 lines
    574 571   def _LatestVersionNotAvailable():
    575 572   if forceCheck:
    576 573   systemErrorExit(4, 'GYB Latest Version information not available')
    577  - last_update_check_file = os.path.join(getConfigPath(), 'lastcheck.txt')
     574 + last_update_check_file = os.path.join(options.config_folder, 'lastcheck.txt')
    578 575   current_version = __version__
    579 576   now_time = calendar.timegm(time.gmtime())
    580 577   check_url = 'https://api.github.com/repos/jay0lee/got-your-back/releases' # includes pre-releases
    skipped 66 lines
    647 644   httpc = google_auth_httplib2.AuthorizedHttp(credentials, _createHttpObj())
    648 645   if options.debug:
    649 646   extra_args['prettyPrint'] = True
    650  - if os.path.isfile(os.path.join(getConfigPath(), 'extra-args.txt')):
     647 + if os.path.isfile(os.path.join(options.config_folder, 'extra-args.txt')):
    651 648   config = configparser.ConfigParser()
    652 649   config.optionxform = str
    653  - config.read(os.path.join(getConfigPath(), 'extra-args.txt'))
     650 + config.read(os.path.join(options.config_folder, 'extra-args.txt'))
    654 651   extra_args.update(dict(config.items('extra-args')))
    655 652   version = getAPIVer(api)
    656 653   try:
    skipped 4 lines
    661 658   cache_discovery=False,
    662 659   static_discovery=False)
    663 660   except googleapiclient.errors.UnknownApiNameOrVersion:
    664  - disc_file = os.path.join(getConfigPath(), '%s-%s.json' % (api, version))
     661 + disc_file = os.path.join(options.config_folder, '%s-%s.json' % (api, version))
    665 662   if os.path.isfile(disc_file):
    666 663   f = file(disc_file, 'r')
    667 664   discovery = f.read()
    skipped 12 lines
    680 677   credentials = getSvcAcctCredentials(scopes, auth_as)
    681 678   if options.debug:
    682 679   extra_args['prettyPrint'] = True
    683  - if os.path.isfile(os.path.join(getConfigPath(), 'extra-args.txt')):
     680 + if os.path.isfile(os.path.join(options.config_folder, 'extra-args.txt')):
    684 681   config = configparser.ConfigParser()
    685 682   config.optionxform = str
    686 683   config.read(getGamPath()+'extra-args.txt')
    skipped 180 lines
    867 864   kwargs['login_hint'] = login_hint
    868 865   # Needs to be set so oauthlib doesn't puke when Google changes our scopes
    869 866   os.environ['OAUTHLIB_RELAX_TOKEN_SCOPE'] = 'true'
    870  - if not os.path.isfile(os.path.join(getConfigPath(), 'oauthbrowser.txt')):
     867 + if not os.path.isfile(os.path.join(options.config_folder, 'oauthbrowser.txt')):
    871 868   flow.run_console(
    872 869   authorization_prompt_message=MESSAGE_CONSOLE_AUTHORIZATION_PROMPT,
    873 870   authorization_code_message=MESSAGE_CONSOLE_AUTHORIZATION_CODE,
    skipped 144 lines
    1018 1015   "token_uri": "https://accounts.google.com/o/oauth2/token"
    1019 1016   }
    1020 1017  }''' % (client_id, client_secret, projectId)
    1021  - client_secrets_file = os.path.join(getConfigPath(), 'client_secrets.json')
     1018 + client_secrets_file = os.path.join(options.config_folder, 'client_secrets.json')
    1022 1019   writeFile(client_secrets_file, cs_data, continueOnError=False)
    1023 1020   
    1024 1021  PROJECTID_PATTERN = re.compile(r'^[a-z][a-z0-9-]{4,28}[a-z0-9]$')
    skipped 14 lines
    1039 1036   sys.exit(3)
    1040 1037   login_hint = getValidateLoginHint(login_hint)
    1041 1038   crm, _ = getCRMService(login_hint)
    1042  - client_secrets_file = os.path.join(getConfigPath(), 'client_secrets.json')
     1039 + client_secrets_file = os.path.join(options.config_folder, 'client_secrets.json')
    1043 1040   if pfilter == 'current':
    1044 1041   cs_data = readFile(client_secrets_file, mode='rb', continueOnError=True, displayError=True, encoding=None)
    1045 1042   if not cs_data:
    skipped 40 lines
    1086 1083   pass
    1087 1084   
    1088 1085  def doCreateProject():
    1089  - service_account_file = os.path.join(getConfigPath(), 'oauth2service.json')
    1090  - client_secrets_file = os.path.join(getConfigPath(), 'client_secrets.json')
     1086 + service_account_file = os.path.join(options.config_folder, 'oauth2service.json')
     1087 + client_secrets_file = os.path.join(options.config_folder, 'client_secrets.json')
    1091 1088   for a_file in [service_account_file, client_secrets_file]:
    1092 1089   if os.path.exists(a_file):
    1093 1090   print('File %s already exists. Please delete or rename it before attempting to create another project.' % a_file)
    skipped 117 lines
    1211 1208  MESSAGE_INSTRUCTIONS_OAUTH2SERVICE_JSON = 'Please run\n\ngyb --action create-project\ngyb --action check-service-account\n\nto create and configure a service account.'
    1212 1209  def getSvcAcctCredentials(scopes, act_as):
    1213 1210   try:
    1214  - json_string = readFile(os.path.join(getConfigPath(), 'oauth2service.json'), continueOnError=True, displayError=True)
     1211 + json_string = readFile(os.path.join(options.config_folder, 'oauth2service.json'), continueOnError=True, displayError=True)
    1215 1212   if not json_string:
    1216 1213   print(MESSAGE_INSTRUCTIONS_OAUTH2SERVICE_JSON)
    1217 1214   systemErrorExit(6, None)
    skipped 10 lines
    1228 1225   
    1229 1226  def getSvcAccountClientId():
    1230 1227   try:
    1231  - json_string = readFile(os.path.join(getConfigPath(), 'oauth2service.json'), continueOnError=True, displayError=True)
     1228 + json_string = readFile(os.path.join(options.config_folder, 'oauth2service.json'), continueOnError=True, displayError=True)
    1232 1229   if not json_string:
    1233 1230   print(MESSAGE_INSTRUCTIONS_OAUTH2SERVICE_JSON)
    1234 1231   systemErrorExit(6, None)
    skipped 190 lines
    1425 1422   print("Error: you did not authorize the OAuth token in the browser with the \
    1426 1423  %s Google Account. Please make sure you are logged in to the correct account \
    1427 1424  when authorizing the token in the browser." % auth_as)
    1428  - cfgFile = os.path.join(getConfigPath(), '%s.cfg' % auth_as)
     1425 + cfgFile = os.path.join(options.config_folder, '%s.cfg' % auth_as)
    1429 1426   os.remove(cfgFile)
    1430 1427   return False
    1431 1428   
    skipped 273 lines
    1705 1702   if options.version:
    1706 1703   print(getGYBVersion())
    1707 1704   print('Path: %s' % getProgPath())
    1708  - print('ConfigPath: %s' % getConfigPath())
     1705 + print('ConfigPath: %s' % options.config_folder)
    1709 1706   print(ssl.OPENSSL_VERSION)
    1710 1707   anonhttpc = _createHttpObj()
    1711 1708   headers = {'User-Agent': getGYBVersion(' | ')}
    skipped 670 lines
    2382 2379   print('ERROR: --action revoke does not work with --service-account')
    2383 2380   sys.exit(5)
    2384 2381   auth_as = options.use_admin if options.use_admin else options.email
    2385  - oauth2file = os.path.join(getConfigPath(), '%s.cfg' % auth_as)
     2382 + oauth2file = os.path.join(options.config_folder, '%s.cfg' % auth_as)
    2386 2383   credentials = getOauth2TxtStorageCredentials()
    2387 2384   if credentials is None:
    2388 2385   return
    skipped 77 lines
Please wait...
Page is in error, reload to recover