Beispiel #1
0
 def setup_completer(self):
     if not self.cfSlugs or not self.wowiSlugs:
         # noinspection PyBroadException
         try:
             self.cfSlugs = pickle.load(gzip.open(io.BytesIO(
                 requests.get('https://storage.googleapis.com/cursebreaker/cfslugs.pickle.gz',
                              headers=HEADERS).content)))
             self.wowiSlugs = pickle.load(gzip.open(io.BytesIO(
                 requests.get('https://storage.googleapis.com/cursebreaker/wowislugs.pickle.gz',
                              headers=HEADERS).content)))
         except Exception:
             self.cfSlugs = []
             self.wowiSlugs = []
     commands = ['install', 'uninstall', 'update', 'force_update', 'wa_update', 'status', 'orphans', 'search',
                 'import', 'export', 'toggle_backup', 'toggle_dev', 'toggle_wa', 'set_wa_api', 'set_wa_wow_account',
                 'uri_integration', 'help', 'exit']
     addons = sorted(self.core.config['Addons'], key=lambda k: k['Name'].lower())
     for addon in addons:
         commands.extend([f'uninstall {addon["Name"]}', f'update {addon["Name"]}', f'force_update {addon["Name"]}',
                          f'toggle_dev {addon["Name"]}', f'status {addon["Name"]}'])
     for item in self.cfSlugs:
         commands.append(f'install cf:{item}')
     for item in self.wowiSlugs:
         commands.append(f'install wowi:{item}')
     commands.extend(['install ElvUI', 'install ElvUI:Dev', 'install Tukui'])
     wa = WeakAuraUpdater('', '', '')
     accounts = wa.get_accounts()
     for account in accounts:
         commands.append(f'set_wa_wow_account {account}')
     self.completer = WordCompleter(commands, ignore_case=True, sentence=True)
 def c_wa_update(self, _, verbose=True):
     if os.path.isdir(Path('Interface/AddOns/WeakAuras')):
         wa = WeakAuraUpdater(
             '' if self.core.config['WAUsername'] == 'DISABLED' else
             self.core.config['WAUsername'],
             self.core.config['WAAccountName'],
             self.core.config['WAAPIKey'])
         accounts = wa.get_accounts()
         if len(accounts) > 1:
             if verbose:
                 printft(
                     HTML(
                         'More than one WoW account detected.\nPlease use <ansiwhite>set_wa_wow_account</ansiwh'
                         'ite> command to set the correct account name.'))
             else:
                 printft(
                     HTML(
                         '\n<ansigreen>More than one WoW account detected.</ansigreen>\nPlease use <ansiwhite>s'
                         'et_wa_wow_account</ansiwhite> command to set the correct account name.'
                     ))
             return
         if wa.accountName:
             if not self.core.config['WAAccountName']:
                 self.core.config['WAAccountName'] = wa.accountName
                 self.core.save_config()
             if self.core.waCompanionVersion != self.core.config[
                     'WACompanionVersion']:
                 self.core.config[
                     'WACompanionVersion'] = self.core.waCompanionVersion
                 self.core.save_config()
                 force = True
             else:
                 force = False
             wa.parse_storage()
             status = wa.check_updates()
             wa.install_companion(self.core.clientType, force)
             wa.install_data()
             if verbose:
                 printft(HTML('<ansigreen>Outdated WeakAuras:</ansigreen>'))
                 for aura in status[0]:
                     printft(aura)
                 printft(
                     HTML('\n<ansigreen>Detected WeakAuras:</ansigreen>'))
                 for aura in status[1]:
                     printft(aura)
             else:
                 printft(
                     HTML(
                         f'\n<ansigreen>The number of outdated WeakAuras:</ansigreen> {len(status[0])}'
                     ))
     elif verbose:
         printft('WeakAuras addon is not installed.')