def fetch_dependencies(repo_path):
    cprint.bold('\n- Looking for dependencies..')

    dependencies_path = repo_path + '/' + DEPENDENCY_FILE

    # List containing only the target_path(s), i.e: 'vendor/google'
    syncable_repos = []
    if os.path.exists(dependencies_path):
        # Load up *.dependencies
        dependencies = None
        with open(dependencies_path, 'r') as dep_file:
            dependencies = json.loads(dep_file.read())
            dep_file.close()

        if len(dependencies) == 0:
            color_exit('%s exists but it is empty.' % DEPENDENCY_FILE)

        # List containing the repositories to be added inside LOCAL_MANIFEST
        fetch_list = []
        for dep in dependencies:
            org, name, remote = process_repo(dep['repository'])

            # If it's not a valid entry (regex fails)
            if not org:
                cprint.warn(
                    "Skipping %s as it's not valid.\nPlease check its syntax in %s."
                    % (dep['repository'], DEPENDENCY_FILE))
                continue

            # If the dependency is not inside the LOCAL_MANIFEST
            if not is_in_manifest(org + '/' + name, dep['branch']):
                fetch_list.append(dep)

            # If the repository doesn't exist, append it to the syncable repos
            if not os.path.exists(dep['target_path']):
                syncable_repos.append(dep['target_path'])

        # If new manifest entries have to be added
        if fetch_list:
            cprint.bold('\n- Adding dependencies to local manifest..')
            add_to_manifest(fetch_list)

        # Synchronise repos
        if syncable_repos:
            cprint.bold('\n- Syncing dependencies..')
            sync_repos(syncable_repos)

    else:
        color_exit('Dependencies file not found, bailing out.')
Пример #2
0
 def run(self):
     """основной цикл потока"""
     self.log.info('start thread ' + str(self.kwargs['args'][0]['name']))
     args = self.kwargs['args']
     try:
         self._try_connect_to_plc()
         self._try_to_connect_db()
         self._reconnect_to_plc()
     except:
         cprint.warn('Error in main ')
     # main cycle
     while True:
         tstart = datetime.datetime.now()
         if self not in MyThread:
             break
         if self.stopped():
             return False
         for i in args[0]['data']:
             try:
                 if not self._write_data_to_db(i):
                     if not self.destroyThread:
                         main(args[1])
                     return False
             except:
                 if not self.destroyThread:
                     main(args[1])
                 return False
         if (self._exception):
             th.connections[args[1]]['status'] = False
             th.connections[args[1]]['status'] = False
             cprint.warn('Error getter value')
             self.log.warning('stop thread ' +
                              str(self.kwargs['args'][0]['name']) +
                              " by error get value")
             time.sleep(float(args[0]['reconnect']))
             if not self.destroyThread:
                 main(args[1])
             return False
         else:
             cprint.info('data returned')
             tend = datetime.datetime.now()
             print('thread', tend - tstart)
             time.sleep(float(args[0]['timeout']))
Пример #3
0
 def _reconnect_to_plc(self):
     """if connection with  PLC  not established stop this tread and create new"""
     if (not self.started):
         self.log.warning('stop thread ' +
                          str(self.kwargs['args'][0]['name']) +
                          " by no connection to plc")
         cprint.warn('error conection to plc ' +
                     str(self.kwargs['args'][0]['name']) + " count - " +
                     str(self.kwargs['args'][1]))
         time.sleep(int(self.kwargs['args'][0]['reconnect']))
         if not self.destroyThread:
             self._c.close()
             try:
                 self._conn.close()
             except:
                 print('qursor sql error')
             self.log.warning('restart thread ' +
                              str(self.kwargs['args'][0]['name']))
             main(self.kwargs['args'][1])
         self.stop()
Пример #4
0
    exclude = []
    if args.exclude:
        exclude = args.exclude[0].split(',')

    for change in change_numbers:
        patchset = None
        if '/' in change:
            (change, patchset) = change.split('/')

        if change in exclude:
            continue

        change = int(change)
        review = next((x for x in reviews if x['number'] == change), None)
        if review is None:
            cprint.warn('Change %d not found, skipping' % change)
            continue

        mergables.append({
            'subject': review['subject'],
            'project': review['project'],
            'branch': review['branch'],
            'change_id': review['change_id'],
            'change_number': review['number'],
            'status': review['status'],
            'fetch': None,
            'patchset': review['revisions'][review['current_revision']]['_number'],
        })

        mergables[-1]['fetch'] = review['revisions'][
            review['current_revision']]['fetch']
Пример #5
0
             format(product))

    # Whether we need to just fetch dependencies or not
    if len(sys.argv) > 2:
        depsonly = sys.argv[2]
    else:
        depsonly = None

    # Setting up local_manifests folder
    if not os.path.exists(LOCAL_MANIFEST_PATH):
        os.makedirs(LOCAL_MANIFEST_PATH)

    # If the device lunched doesn't exist in a local directory, try to sync it from the remote repo
    if not depsonly:
        cprint.warn(
            'Device not found in local repositories.\nAttempting to retrieve it from %s..'
            % DEFAULT_ORG)

        # Construct Organisation/android_device_<product>_<device> string
        device_repo = gather_device_repo(device)

        if device_repo:
            cprint.success(
                'Device repository exists on remote, preparing synchronization..'
            )

            # product can be get from device_repo by splitting
            product = device_repo.split('_')[2]
            # Target path
            repo_path = 'device/%s/%s' % (product, device)