예제 #1
0
    def compute(self):
        q = Quantizator()
        m = Maskerator()
        c = Cropper()
        b = Builder()

        # load the image and resize it to a smaller factor so that
        # the shapes can be approximated better
        image = cv2.imread('./temp/image.jpg')
        # resize image
        resized = cv2.resize(image, (960, 1280), interpolation=cv2.INTER_AREA)
        cv2.imwrite('./temp/original.jpg', resized)

        q.quantize(32)
        m.mask()
        assemblyInstructions = c.crop()
        b.build(assemblyInstructions)

        with open('./json/data.json', 'r') as f:
            return f.read()
예제 #2
0
def build(*args, **kwargs):
    """
    Command that performs thet gets a GIT repository, compiles some files and pushes them to another repository
    If build is not OK it send an email with the changelog and the error
    :param args: 
    :param kwargs: build command arguments
    :return: 
    """
    result = 0
    with open(kwargs['config']) as f:
        config = json.load(f)

    print('This is your current config:\n{}'.format(
        pprint.pformat(config, indent=2, width=120)))
    if bool_input('Do you want to continue?'):

        last_execution = datetime.datetime.strptime(config["last_execution"], "%Y-%m-%d %H:%M:%S.%f") \
            if config["last_execution"] else datetime.datetime(1900, 1, 1)

        email = Email(
            config["email"]["smtp_server"],
            config["email"]["smtp_port"],
            config["email"]["username"],
            config["email"]["password"],
        )

        origin_repo = GitRepository(config["git_origin"]["repo_path"],
                                    config["git_origin"]["git_repo"])
        target_repo = GitRepository(
            config["git_target"]["target_path"],
            config["git_target"]["git_target"].format(
                config["git_origin"]["git_user"],
                config["git_origin"]["git_pass"]))

        builder = Builder(origin=origin_repo, target=target_repo, email=email)

        build_ok = builder.build(config["git_origin"]["build_file"])

        if build_ok:
            builder.push_binary(config["git_target"]["files"])
            config["last_execution"] = str(datetime.datetime.now())

            with open(kwargs['config'], "w") as f:
                json.dump(config, f)
            print("Success")
        else:
            builder.send_email_error(last_execution,
                                     config["email"]["email_from"],
                                     config["email"]["email_to"],
                                     config["email"]["subject"])

        result = 0 if build_ok else -1
    return result
예제 #3
0
def deploy():
    b = Builder()
    b.build()
    u = SFTPUploader()
    u.upload()
예제 #4
0
def build():
    b = Builder()
    b.build()