Example #1
0
    def __init__(self, bypass_remotes: bool = False, bypass_outlets: bool = False):
        self.menu = Menu("main_menu")
        self.local = Local()
        if not bypass_outlets and config.cfg.get('power'):
            self.pwr_init_complete = False
            self.pwr = Outlets()
        else:
            self.pwr_init_complete = True
            self.pwr = None
        self.cpiexec = ConsolePiExec(config, self.pwr, self.local, self.menu)
        if not bypass_remotes:
            self.remotes = Remotes(self.local, self.cpiexec)

        # TODO Move to menu launch and prompt user
        # verify TELNET is installed and install if not if hosts of type TELNET are defined.
        if config.hosts:
            utils.verify_telnet_installed(config.hosts)
Example #2
0
                        remote_consoles[row[0]]['source'] = 'cloud'
                    x += 1
                log.debugv(f'[GDRIVE]: {len(remote_consoles)} Remote ConsolePis Found on Gdrive: \n{json.dumps(remote_consoles)}')
            range_ = 'a' + str(cnt) + ':b' + str(cnt)

            # -- // Update gdrive with this ConsolePis data \\ --
            if not config.cloud_pull_only:
                if found:
                    log.info('[GDRIVE]: Updating ' + str(k) + ' data found on row ' + str(cnt) + ' of Google Drive config')
                    request = service.spreadsheets().values().update(spreadsheetId=spreadsheet_id, range=range_,
                                                                     valueInputOption=value_input_option, body=value_range_body)
                else:
                    log.info('[GDRIVE]: Adding ' + str(k) + ' to Google Drive Config')
                    request = service.spreadsheets().values().append(spreadsheetId=spreadsheet_id, range=range_,
                                                                     valueInputOption=value_input_option, body=value_range_body)
                self.exec_request(request)
            else:
                log.info('cloud_pull_only override enabled not updating cloud with data from this host')
            cnt += 1
        self.resize_cols()
        return remote_consoles


if __name__ == '__main__':
    print('-- Syncing Data With Google Drive --')
    from consolepi.local import Local  # type: ignore
    local = Local()
    gdrive = GoogleDrive()
    data = gdrive.update_files(local.data)
    print(json.dumps(data, indent=4, sort_keys=True) if 'Gdrive-Error' not in data else data)