Beispiel #1
0
    def test_process_tpl_str(self):

        logger.info("Testing template string processing...")

        self.assertEqual(Utils.process_tpl_str("Hello ${name}!", {'name': "World"}), "Hello World!")

        self.assertEqual(Utils.process_tpl_str("${name} ${name} ${name}", {'name': "OK"}), "OK OK OK")
Beispiel #2
0
    def test_icons(self):

        logger.info("Testing icons...")

        settings = Utils.get_config("settings.ini")
        output_path = os.path.join(settings['output_dir'], settings['build_folder'])

        Utils.create_icons(settings["imagemagick_dir"], os.path.join(settings["images_dir"], settings["bitclone_logo"]), output_path, settings["icons"])
Beispiel #3
0
    def test_process_tpl(self):

        logger.info("Testing template processing...")

        tpl_path = os.path.join(self.dir_path, "resources", "test_template.tpl")
        output_file_path = os.path.join(self.dir_path, "resources", "test_output_file.txt")

        Utils.process_tpl(tpl_path, output_file_path, {'name': "OK"})

        self.assertEqual(Utils.read_file(output_file_path), "OK OK OK")
Beispiel #4
0
    def test_process_tpl_str(self):

        logger.info("Testing template string processing...")

        self.assertEqual(
            Utils.process_tpl_str("Hello ${name}!", {'name': "World"}),
            "Hello World!")

        self.assertEqual(
            Utils.process_tpl_str("${name} ${name} ${name}", {'name': "OK"}),
            "OK OK OK")
Beispiel #5
0
    def test_images(self):

        logger.info("Testing image creation...")

        settings = Utils.get_config("settings.ini")
        output_path = os.path.join(settings['output_dir'],
                                   settings['build_folder'])
        logo_path = os.path.join(settings["images_dir"],
                                 settings["bitclone_logo"])

        Utils.create_images(settings["imagemagick_dir"], settings, logo_path,
                            output_path)
Beispiel #6
0
    def test_process_tpl(self):

        logger.info("Testing template processing...")

        tpl_path = os.path.join(self.dir_path, "resources",
                                "test_template.tpl")
        output_file_path = os.path.join(self.dir_path, "resources",
                                        "test_output_file.txt")

        Utils.process_tpl(tpl_path, output_file_path, {'name': "OK"})

        self.assertEqual(Utils.read_file(output_file_path), "OK OK OK")
Beispiel #7
0
    def test_splash(self):

        logger.info("Testing splash...")

        settings = Utils.get_config("settings.ini")
        output_path = os.path.join(settings['output_dir'], settings['build_folder'])
        splash_path = os.path.join(settings["images_dir"], settings["bitclone_splash"])
        logo_path = os.path.join(settings["images_dir"], settings["bitclone_logo"])
        logo_text_path = os.path.join(settings["images_dir"], settings["bitclone_logo_text"])
        show_bitclone = True

        Utils.create_splash(settings["imagemagick_dir"], 'BITCLONE', settings["version"], splash_path, logo_path, logo_text_path, show_bitclone, output_path, settings['splash_image'])
Beispiel #8
0
    def test_splash(self):

        logger.info("Testing splash...")

        settings = Utils.get_config("settings.ini")
        output_path = os.path.join(settings['output_dir'],
                                   settings['build_folder'])
        splash_path = os.path.join(settings["images_dir"],
                                   settings["bitclone_splash"])
        logo_path = os.path.join(settings["images_dir"],
                                 settings["bitclone_logo"])
        logo_text_path = os.path.join(settings["images_dir"],
                                      settings["bitclone_logo_text"])
        show_bitclone = True

        Utils.create_splash(settings["imagemagick_dir"], 'BITCLONE',
                            settings["version"], splash_path, logo_path,
                            logo_text_path, show_bitclone, output_path,
                            settings['splash_image'])
Beispiel #9
0
import os
import unittest
from lib.commons import Utils

logger = Utils.get_logger()


class CommonsTestCase(unittest.TestCase):

    dir_path = os.path.dirname(os.path.realpath(__file__))

    def test_process_tpl_str(self):

        logger.info("Testing template string processing...")

        self.assertEqual(
            Utils.process_tpl_str("Hello ${name}!", {'name': "World"}),
            "Hello World!")

        self.assertEqual(
            Utils.process_tpl_str("${name} ${name} ${name}", {'name': "OK"}),
            "OK OK OK")

        #with self.assertRaises(KeyError) as context:
        #Utils.process_tpl_str("Make my ${something}", {'name': "day"})

    def test_process_tpl(self):

        logger.info("Testing template processing...")

        tpl_path = os.path.join(self.dir_path, "resources",
Beispiel #10
0
def main():

    logger.info("Running Bitcoin Builder...")

    settings = Utils.get_config("settings.ini")
    templates = settings['templates']
    output_path = os.path.join(settings['output_dir'],
                               settings['build_folder'])
    zip_dir = settings['zip_dir']

    if os.path.isfile(zip_dir):
        os.remove(zip_dir)

    if os.path.isdir(output_path):
        shutil.rmtree(output_path)

    shutil.copytree(settings['templates_dir'], output_path)
    shutil.copytree(settings['git_dir'], os.path.join(output_path, ".git"))

    for template in templates:
        if "*" in template:

            tpl_path = os.path.join(output_path, template.split("*")[0])
            tpl_ext = template.split("*")[1]
            files = os.listdir(tpl_path)

            for file in files:
                tpl_path2 = os.path.join(tpl_path, file)
                if os.path.isfile(tpl_path2) and tpl_path2.endswith(tpl_ext):
                    logger.info("Processing template: " + tpl_path2)
                    Utils.process_tpl(tpl_path2, tpl_path2, settings)
        else:

            tpl_path = os.path.join(output_path, template)
            logger.info("Processing template: " + tpl_path)
            Utils.process_tpl(tpl_path, tpl_path, settings)

    # rename build file to coin name
    os.rename(os.path.join(output_path, settings['build_file']),
              os.path.join(output_path, settings['bcl_name'] + ".pro"))

    # generate icons
    Utils.create_icons(
        settings['imagemagick_dir'],
        os.path.join(settings["images_dir"], settings["bitclone_logo"]),
        output_path, settings["icons"])

    # generate splash screen
    logger.info("Testing splash...")

    splash_path = os.path.join(settings["images_dir"],
                               settings["bitclone_splash"])
    logo_path = os.path.join(settings["images_dir"], settings["bitclone_logo"])
    logo_text_path = os.path.join(settings["images_dir"],
                                  settings["bitclone_logo_text"])
    show_bitclone = True if settings["show_bitclone"] == "true" else False

    Utils.create_splash(img_magick_path=settings["imagemagick_dir"],
                        coin_name=str(settings['bcl_name']).upper(),
                        version=settings["version"],
                        splash_path=splash_path,
                        logo_path=logo_path,
                        logo_text_path=logo_text_path,
                        show_bitclone=show_bitclone,
                        output_path=output_path,
                        output_file=settings['splash_image'])

    Utils.create_images(settings["imagemagick_dir"], settings, logo_path,
                        output_path)

    os.chdir(settings['output_dir'])

    Utils.exec_cmd(settings['zip_bin'] + " -r " + zip_dir + " bitcoin")
Beispiel #11
0
def main():

    logger.info("Running Bitcoin Builder...")

    settings = Utils.get_config("settings.ini")
    templates = settings['templates']
    output_path = os.path.join(settings['output_dir'], settings['build_folder'])
    zip_dir = settings['zip_dir']

    if os.path.isfile(zip_dir):
        os.remove(zip_dir)

    if os.path.isdir(output_path):
        shutil.rmtree(output_path)

    shutil.copytree(settings['templates_dir'], output_path)
    shutil.copytree(settings['git_dir'], os.path.join(output_path, ".git"))

    for template in templates:
        if "*" in template:

            tpl_path = os.path.join(output_path, template.split("*")[0])
            tpl_ext = template.split("*")[1]
            files = os.listdir(tpl_path)

            for file in files:
                tpl_path2 = os.path.join(tpl_path, file)
                if os.path.isfile(tpl_path2) and tpl_path2.endswith(tpl_ext):
                    logger.info("Processing template: " + tpl_path2)
                    Utils.process_tpl(tpl_path2, tpl_path2, settings)
        else:

            tpl_path = os.path.join(output_path, template)
            logger.info("Processing template: " + tpl_path)
            Utils.process_tpl(tpl_path, tpl_path, settings)

    # rename build file to coin name
    os.rename(os.path.join(output_path, settings['build_file']), os.path.join(output_path, settings['bcl_name'] + ".pro"))

    # generate icons
    Utils.create_icons(settings['imagemagick_dir'], os.path.join(settings["images_dir"], settings["bitclone_logo"]), output_path, settings["icons"])

    # generate splash screen
    logger.info("Testing splash...")

    splash_path = os.path.join(settings["images_dir"], settings["bitclone_splash"])
    logo_path = os.path.join(settings["images_dir"], settings["bitclone_logo"])
    logo_text_path = os.path.join(settings["images_dir"], settings["bitclone_logo_text"])
    show_bitclone = True if settings["show_bitclone"] == "true" else False

    Utils.create_splash(
        img_magick_path=settings["imagemagick_dir"],
        coin_name=str(settings['bcl_name']).upper(),
        version=settings["version"],
        splash_path=splash_path,
        logo_path=logo_path,
        logo_text_path=logo_text_path,
        show_bitclone=show_bitclone,
        output_path=output_path,
        output_file=settings['splash_image']
    )

    Utils.create_images(settings["imagemagick_dir"], settings, logo_path, output_path)

    os.chdir(settings['output_dir'])

    Utils.exec_cmd(settings['zip_bin'] + " -r " + zip_dir + " bitcoin")
Beispiel #12
0
import os
import shutil
import subprocess
from lib.commons import Utils

logger = Utils.get_logger()


def main():

    logger.info("Running Bitcoin Builder...")

    settings = Utils.get_config("settings.ini")
    templates = settings['templates']
    output_path = os.path.join(settings['output_dir'], settings['build_folder'])
    zip_dir = settings['zip_dir']

    if os.path.isfile(zip_dir):
        os.remove(zip_dir)

    if os.path.isdir(output_path):
        shutil.rmtree(output_path)

    shutil.copytree(settings['templates_dir'], output_path)
    shutil.copytree(settings['git_dir'], os.path.join(output_path, ".git"))

    for template in templates:
        if "*" in template:

            tpl_path = os.path.join(output_path, template.split("*")[0])
            tpl_ext = template.split("*")[1]