Beispiel #1
0
def main(args):
    if args.configfile is None and args.configfolder is None:
        raise ValueError('No configuration file(s) specified')
    if args.configfile is not None and args.configfolder is not None:
        raise ValueError(
            'Please specify either a single config file or a folder, not both.'
        )

    if args.configfile is not None:
        try:
            configuration = config_loader.load_from_file(args.configfile)
        except Exception as exception:
            logger.critical(f'Error loading configuration: {exception}')
            raise

    if args.configfolder is not None:
        try:
            configuration = config_loader.load_from_folder(args.configfolder)
        except Exception as exception:
            logger.critical(f'Error loading configuration: {exception}')
            raise

    worker.process(configuration)

    if args.watch and args.configfile is not None:
        config_watcher.watch_configurationfile(args.configfile)

    if args.watch and args.configfolder is not None:
        config_watcher.watch_configurationfolder(args.configfolder)
Beispiel #2
0
def process_upload_multiple(files, callback_url=None):
    id = utils.generate_id()
    d = utils.storage_dir_for_id(id)
    os.makedirs(d)
   
    file_id = 0
    session = database.Session()
    m = database.model(id, '')   
    session.add(m)
  
    for file in files:
        fn = file.filename
        filewriter = lambda fn: file.save(fn)
        filewriter(os.path.join(d, id+"_"+str(file_id)+".ifc"))
        file_id += 1
        m.files.append(database.file(id, ''))
    
    session.commit()
    session.close()
    
    if DEVELOPMENT:
        t = threading.Thread(target=lambda: worker.process(id, callback_url))
        t.start()        
    else:
        q.enqueue(worker.process, id, callback_url)

    return id
Beispiel #3
0
def process_task(taskId):
    with app.app_context():
        try:
            task = db.session.query(Task).filter(Task.id == taskId).one()
            task.status = 'deploying'
            db.session.commit()
            steps = Step.query.filter(Step.taskId == taskId).all()

            returncode = 0
            for step in steps:
                returncode = worker.process(step.content, step.id)

                logger.info("returncode for step %s is %s" % (step.id, returncode))

                step.log = worker.logs.get(step.id, '')
                logger.info(worker.logs)
                if worker.logs.has_key(step.id):
                    worker.logs.pop(step.id)
                if returncode != 0:
                    step.status = 'failed'
                else:
                    step.status = 'success'
                db.session.commit()

                if step.status == 'failed':
                    break
            if returncode != 0:
                task.status = 'failed'
            else:
                task.status = 'success'
            db.session.commit()
            # del process_tasks[task.id]
        except Exception, e:
            logger.error('error while process task %s' % task.id)
            logger.error(traceback.format_exc())
Beispiel #4
0
def run():
    mat = camera.tomat().copy()
    #picture = mat.copy()
    picture, coords, _ = worker.process(mat, dconn.dinput)
    #print(cconn.movement)
    if cconn.movement != "":
        if cconn.movement[4] == 'u':
            if cconn.movement[0] == 'u' and cconn.movement[2] == 'u':
                car.car.stopY()
            if cconn.movement[1] == 'u' and cconn.movement[3] == 'u':
                car.car.stopX()
            if cconn.movement[0] == 'p':
                car.car.moveForward()
            if cconn.movement[1] == 'p':
                car.car.turnRight()
            if cconn.movement[2] == 'p':
                car.car.moveBackward()
            if cconn.movement[3] == 'p':
                car.car.turnLeft()
        elif cconn.movement[4] == 'p':
            if coords:
                iconn.found = True
                print("Feeding " + str(coords))
                car.feed(coords)
            else:
                car.halt()
                iconn.found = False


#	matstr = utils.mattostr(worker.directtorect(mat,coords.cX))
    matstr = utils.mattostr(picture)
    iconn.send(matstr)
Beispiel #5
0
def process_upload(filewriter, callback_url=None):
    id = utils.generate_id()
    d = utils.storage_dir_for_id(id)
    os.makedirs(d)

    filewriter(os.path.join(d, id + ".ifc"))

    session = database.Session()
    session.add(database.model(id, ''))
    session.commit()
    session.close()

    if DEVELOPMENT:
        t = threading.Thread(target=lambda: worker.process(id, callback_url))
        t.start()
    else:
        q.enqueue(worker.process, id, callback_url)

    return id
def index():
    print(request.method)
    if request.method == 'GET':
        print("GET")
        name = {}
        name = json.dumps(name)
        return template('index.html', name=name)
    else:
        print("pust")
        string = request.forms.getunicode('string')
        print(string)
        string = string.encode("utf-8")

        title = request.forms.getunicode('title')
        print(title)
        title = title.encode("utf-8")

        contents_dict = process(string, title)
        print(contents_dict)
        contents_dict = json.dumps(contents_dict)

        return template('index.html', name=contents_dict)
def _on_modifiedfolder(event):
    logger.debug(event)
    logger.info(f'{event.src_path} was modified.  Processing changes.')
    directory = path.dirname(event.src_path)
    configuration = config_loader.load_from_folder(directory)
    worker.process(configuration)
def _on_modifiedfile(event):
    logger.debug(event)
    logger.info(f'{event.src_path} was modified.  Processing changes.')
    configuration = config_loader.load_from_file(event.src_path)
    worker.process(configuration)