Example #1
0
    def update(self):
        data_obj = data.Data()
        build_path = data_obj.get_build_path()
        docker = Client()

        container_name = data_obj.get_path_hash()
        container_obj = container.Container(container_name)

        print('Installing new build dependencies...')

        build_deps = ""

        for dep in data_obj.get_build_deps_to_install():
            build_deps = build_deps + " " + dep

        for line in container_obj.execute("apt-get install -y " + build_deps):
            print(line, end="")

        print('Removing old build dependencies...')

        build_deps = ""

        for dep in data_obj.get_build_deps_to_remove():
            build_deps = build_deps + " " + dep

        for line in container_obj.execute("apt-get purge -y " + build_deps):
            print(line, end="")

        print('Removing orphaned dependencies...')

        for line in container_obj.execute("apt-get autoremove -y"):
            print(line, end="")

        print("Installing new app dependencies...")

        deps = ""

        for dep in data_obj.get_deps_to_install():
            deps = deps + " " + dep

        for line in container_obj.execute('rm -rf /tmp/debs && mkdir /tmp/debs && cd /tmp/debs && apt-get download ' + deps):
            print(line, end="")

        print('Decompressing new dependencies...')

        container_obj.execute('ls -1 /tmp/debs | while read line ; do dpkg-deb -R /tmp/debs/$line /mnt/appimager/build ; done')

        print('Removing old dependencies...')

        container_obj.execute('ls -1 /tmp/debs | while read line ; do dpkg-deb -R /tmp/debs/$line /mnt/appimager/build ; done')

        print('Configuring permissions...')
        container_obj.execute('chown -R ' + str(os.getuid()) + ':' + str(os.getgid()) + ' /mnt/appimager/build')

        shutil.rmtree('build/DEBIAN')

        print('Writing lock file...')
        data_obj.write_lock_file()

        print("Complete")
Example #2
0
    def build(self):
        data_obj = data.Data()
        container_name = data_obj.get_path_hash()
        container_obj = container.Container(container_name)
        yml_data = data_obj.get_yml_data()

        for line in container_obj.execute('cd /mnt/appimager/cwd && ' +
                                          yml_data['build']):
            print(line, end="")

        if 'integration' in yml_data.keys():
            print('Setting up desktop integration...')
            for line in container_obj.execute(
                    'wget -O /mnt/appimager/build/' + yml_data['integration'] +
                    '.wrapper https://raw.githubusercontent.com/probonopd/AppImageKit/master/desktopintegration'
            ):
                print(line)

            for line in container_obj.execute(
                    'chmod +x /mnt/appimager/build/' +
                    yml_data['integration'] + '.wrapper'):
                print(line)

        print('Configuring permissions...')
        container_obj.execute('chown -R ' + str(os.getuid()) + ':' +
                              str(os.getgid()) + ' /mnt/appimager/build')
Example #3
0
    def package(self):
        data_obj = data.Data()
        container_name = data_obj.get_path_hash()
        container_obj = container.Container(container_name)

        for line in container_obj.execute(
                'AppImageAssistant.AppImage /mnt/appimager/build /mnt/appimager/out/'
                + data_obj.get_name()):
            print(line, end="")
Example #4
0
    def stop(self):
        data_obj = data.Data()
        container_name = data_obj.get_path_hash()
        container_obj = container.Container(container_name)

        print('Stopping container...')

        container_obj.stop()

        print("Container stopped")
Example #5
0
    def start(self):
        data_obj = data.Data()
        container_name = data_obj.get_path_hash()

        docker = container.Container(container_name)

        print('Starting container...')

        docker.start()

        print("Container started")
Example #6
0
    def build(self):
        data_obj = data.Data()
        container_name = data_obj.get_path_hash()
        container_obj = container.Container(container_name)
        yml_data = data_obj.get_yml_data()

        for line in container_obj.execute('cd /mnt/appimager && ' +
                                          yml_data['build']):
            print(line, end="")

        print('Configuring permissions...')
        container_obj.execute('chown -R ' + str(os.getuid()) + ':' +
                              str(os.getgid()) + ' /mnt/appimager/build')
Example #7
0
    def destroy(self):
        data_obj = data.Data()
        container_name = data_obj.get_path_hash()
        container_obj = container.Container(container_name)

        print('Stopping container...')

        container_obj.stop()

        print('Destroying container...')

        container_obj.destroy()

        print("Container destroyed")
Example #8
0
    def install(self):
        data_obj = data.Data()
        build_path = data_obj.get_build_path()
        docker = Client()

        if not os.path.exists(build_path):
            print("Creating build directory")
            os.mkdir(build_path)

        container_name = data_obj.get_path_hash()
        container_obj = container.Container(container_name)

        print("Downloading app dependencies...")

        deps = ""

        for dep in data_obj.get_deps():
            deps = deps + " " + dep

        for line in container_obj.execute('rm -rf /tmp/debs && mkdir /tmp/debs && cd /tmp/debs && apt-get download ' + deps):
            print(line, end="")

        print('Decompressing dependencies...')

        for line in container_obj.execute('ls -1 /tmp/debs | while read line ; do dpkg-deb -R /tmp/debs/$line /mnt/appimager/build ; done'):
            print(line)

        print('Configuring permissions...')
        container_obj.execute('chown -R ' + str(os.getuid()) + ':' + str(os.getgid()) + ' /mnt/appimager/build')

        shutil.rmtree('build/DEBIAN')

        print('Writing lock file...')
        data_obj.write_lock_file()

        print("Complete")
Example #9
0
    def setup(self):
        data_obj = data.Data()
        yml = data_obj.get_yml_data()

        docker = Client()

        print('Setting up environment, please wait...')

        volume = os.getcwd()

        base_os_version = yml['base']
        container_name = data_obj.get_path_hash()

        container_obj = container.Container(container_name)

        print('Pulling Ubuntu ' + str(base_os_version) + '...')
        docker.pull('ubuntu', str(base_os_version))

        print('Creating container...')
        docker.create_container('ubuntu:' + str(base_os_version),
                                tty=True,
                                command="/bin/bash",
                                name=container_name,
                                volumes=['/mnt/appimager'],
                                host_config=docker.create_host_config(
                                    privileged=True,
                                    cap_add=['SYS_ADMIN'],
                                    binds={
                                        os.getcwd(): {
                                            'bind': '/mnt/appimager',
                                            'mode': 'rw',
                                        }
                                    }))

        print('Starting container...')
        container_obj.start()

        print('Updating APT repositories...')

        for line in container_obj.execute("apt-get update"):
            print(line, end="")

        print('Installing common dependencies...')
        for line in container_obj.execute(
                'apt-get -y install software-properties-common python-software-properties'
        ):
            print(line, end="")

        print('Adding additional APT repositories...')
        for repo in data_obj.get_repositories():
            for line in container_obj.execute('add-apt-repository -y ' + repo):
                print(line, end="")

        print('Updating APT repositories...')

        for line in container_obj.execute("apt-get update"):
            print(line, end="")

        print('Installing build dependencies...')

        build_deps = ""

        for dep in data_obj.get_build_deps():
            build_deps = build_deps + " " + dep

        for line in container_obj.execute("apt-get install -y " + build_deps):
            print(line, end="")

        print('Writing lock file...')
        data_obj.write_lock_file()

        print('Setup Complete')
Example #10
0
import logging
import pandas as pd
from tabulate import tabulate

from core import container, operations
from core.random_generators import SequencialGenerator, FakerGenerator, NumpyRandomGenerator, ConstantDependentGenerator, ConstantGenerator
import core.util_functions as util_functions

util_functions.setup_logging()

example_circus = container.Container(name="example",
                                     master_seed=12345,
                                     start=pd.Timestamp("1 Jan 2017 00:00"),
                                     step_duration=pd.Timedelta("1h"))

id_gen = SequencialGenerator(prefix="PERSON_")
age_gen = NumpyRandomGenerator(method="normal",
                               loc=3,
                               scale=5,
                               seed=next(example_circus.seeder))
name_gen = FakerGenerator(method="name", seed=next(example_circus.seeder))

person = example_circus.create_population(name="person",
                                          size=1000,
                                          ids_gen=id_gen)
person.create_attribute("NAME", init_gen=name_gen)
person.create_attribute("AGE", init_gen=age_gen)

hello_world = example_circus.create_story(
    name="hello_world",
    initiating_population=example_circus.populations["person"],
Example #11
0
    def setup(self):
        data_obj = data.Data()
        yml = data_obj.get_yml_data()

        docker = Client()

        print('Setting up environment, please wait...')

        volume = os.getcwd()

        base_os_version = yml['base']
        container_name = data_obj.get_path_hash()

        container_obj = container.Container(container_name)

        print('Pulling Ubuntu ' + str(base_os_version) + '...')
        docker.pull('ubuntu', str(base_os_version))

        data_obj = data.Data()

        print('Creating container...')
        docker.create_container('ubuntu:' + str(base_os_version), tty=True, command="/bin/bash", name=container_name, volumes=['/mnt/appimager'],
            host_config=docker.create_host_config(privileged=True, cap_add=['SYS_ADMIN'], binds={
                os.getcwd(): {
                    'bind': '/mnt/appimager/cwd',
                    'mode': 'ro',
                },
                data_obj.get_work_path(): {
                    'bind': '/mnt/appimager/work',
                    'mode': 'rw',
                },
                data_obj.get_build_path(): {
                    'bind': '/mnt/appimager/build',
                    'mode': 'rw',
                },
                data_obj.get_out_path(): {
                    'bind': '/mnt/appimager/out',
                    'mode': 'rw',
                }
            }))

        print('Starting container...')
        container_obj.start()

        print('Updating APT repositories...')

        for line in container_obj.execute("apt-get update"):
            print(line, end="")

        print('Installing common dependencies...')
        for line in container_obj.execute('apt-get -y install software-properties-common python-software-properties wget fuse'):
            print(line, end="")

        print('Downloading AppImageAssistant...')
        for line in container_obj.execute('wget -O /usr/bin/AppImageAssistant.AppImage https://github.com/probonopd/AppImageKit/releases/download/6/AppImageAssistant_6-' + data_obj.architecture() + '.AppImage && chmod +x /usr/bin/AppImageAssistant.AppImage'):
            print(line, end="")

        print('Adding additional APT repositories...')
        for repo in data_obj.get_repositories():
            for line in container_obj.execute('add-apt-repository -y ' + repo):
                print(line, end="")

        print('Updating APT repositories...')

        for line in container_obj.execute("apt-get update"):
            print(line, end="")

        print('Installing build dependencies...')

        build_deps = ""

        for dep in data_obj.get_build_deps():
            build_deps = build_deps + " " + dep

        for line in container_obj.execute("apt-get install -y " + build_deps):
            print(line, end="")

        print('Writing lock file...')
        data_obj.write_lock_file()

        print('Setup Complete')