Exemplo n.º 1
0
 def _commands(self) -> {}:
     return registerCommands(Deploy, Run)
Exemplo n.º 2
0
from platform.commands.endpoint import Endpoint
from platform.params.params import Params
from platform.utils.utils import registerCommands
from platform.statement.statement import Statement


class Pass(Endpoint):
    def name(self):
        return 'pass'

    def _info(self):
        return ['{path} - ничего не делает, но принимает любые аргументы и опции']

    def _rules(self):
        return [ Statement(['{path} всё_что_угодно'], self.process, lambda p: True) ]

    def process(self, p: Params):
        pass


commands = registerCommands(Pass)
Exemplo n.º 3
0
class Send(SendOrGet, Endpoint):
    def name(self):
        return 'send'

    def _info(self):
        return ['{path} - отправляет файлы на удалённый сервер']

    def _rules(self):
        return self._rules_impl(self.send)

    def send(self, p: Params):
        self._impl(p).send()


class Get(SendOrGet, Endpoint):
    def name(self):
        return 'get'

    def _info(self):
        return ['{path} - получает файлы с удалённого сервера']

    def _rules(self):
        return self._rules_impl(self.get)

    def get(self, p: Params):
        self._impl(p).get()


commands = registerCommands(Send, Get)
Exemplo n.º 4
0
                                            .size().equals(p.delimered[0], 1)
                                            .size().equals(p.delimered[1], 1)
                                            .check().delimersType(DoubleDelimer)) ]

    def _findSecondDelimer(self, args, index = 0):
        i = args.index(DoubleDelimer.value)
        return self._findSecondDelimer(args[i+1:], i+1) if index == 0 else i+index+1

    def run(self, p: Params):
        ws = self.database.selectone(p.delimered[0][0].value, Workspace)
        path = p.delimered[1][0].value

        i = self._findSecondDelimer(p.argv)

        for s in run(ws.host).withstderr().path(join(ws.path, path)).cmd(p.argv[i:]).exec():
            print(s, end='')


class Build(Command):
    def name(self) -> '':
        return 'build'

    def _info(self):
        return ['{path} - составные высокоуровневые команды для упрощения процесса разработки']

    def _commands(self) -> {}:
        return registerCommands(Deploy, Run)


commands = registerCommands(Build)
Exemplo n.º 5
0
from platform.commands.endpoint import Endpoint
from platform.params.params import Params
from platform.utils.utils import registerCommands
from platform.statement.statement import Statement


class Pass(Endpoint):
    def name(self):
        return 'pass'

    def _info(self):
        return [
            '{path} - ничего не делает, но принимает любые аргументы и опции'
        ]

    def _rules(self):
        return [
            Statement(['{path} всё_что_угодно'], self.process, lambda p: True)
        ]

    def process(self, p: Params):
        pass


commands = registerCommands(Pass)
Exemplo n.º 6
0
        d = Statement(['{path} опция значение - устанавливает новое значение для опции',
                       '{path} опция значение1,значение2 - устанавливает значение опции-массива'], self.setOption,
                      lambda p: Rule(p).empty().delimers()
                                       .size().equals(p.targets, 2)
                                       .empty().options())

        return [a, b, c, d]

    def showOptions(self, p: Params):
        print(self.database.config)

    def showOption(self, p: Params):
        print(getattr(self.database.config, p.targets[0].value))

    def setOption(self, p: Params):
        cfg = self.database.config
        attr = p.targets[0].value
        value = p.targets[1].value
        if isinstance(getattr(cfg, attr), list):
            cfg.params[attr] = value.split(',')
        else:
            cfg.params[attr] = value
        self.database.update(cfg)

    def initConfig(self, p: Params):
        initconfig()


commands = registerCommands(Config)
Exemplo n.º 7
0
        maker = Maker(self.database)

        Exist(self.database).project(name)
        project: Project = self.database.selectone(name, Project)

        ws_name = p.options['ws'] if 'ws' in p.options else project.workspace
        Exist(self.database).workspace(ws_name)
        ws: Workspace = self.database.selectone(ws_name, Workspace)

        print()
        print(colored('Запуск сборки', Color.green, Style.underline))
        print('Проект: ' + colored(name, Color.blue))
        print('Путь: ' + colored(project.path, Color.blue))
        print('Инфо: ' + colored(project.__dict__, Color.blue))
        print('Workspace: ' + colored(ws.__dict__, Color.blue))

        test_level = None
        test_level = 't' if 't' in p.options else test_level
        test_level = 'tt' if 'tt' in p.options else test_level
        test_level = 'ttt' if 'ttt' in p.options else test_level

        maker.make(project=project,
                   ws=ws,
                   test_level=test_level,
                   add_tests='add_tests' in p.options,
                   add_build='add_builds' in p.options,
                   need_highlight=not ('nohl' in p.options))


commands = registerCommands(Make)
Exemplo n.º 8
0
            print('Путь: ' + colored(path, Color.blue))
            maker.make(name, path, need_highlight=not ('nohl' in p.options))

    def _syncIncludes(self, project, p: Params):
        if p.options['mode'] != 'do-not-sync':
            print()
            print(colored('Синхронизирую заголовки', Color.green, Style.underline))
            pr = self.database.projects()[project]
            self.subcmd(Get).execute([pr.workspace, '--workspace', '--path=include', '--erase_missing'])

    def makeProjects(self, p: Params):
        makeTargets = [ x.value for x in p.delimered[0] ]
        maker = Maker(self.database, makeTargets, p.options['jobs'])

        for name in [ x.value for x in p.delimered[1] ]:
            self._make(p, maker, name)
            self._syncIncludes(name, p)

    def makeMakefile(self, p: Params):
        makeTargets = [ x.value for x in p.delimered[0] ]
        targets = p.delimered[1]
        name = targets[0].value
        path = targets[1].value
        maker = Maker(self.database, makeTargets, p.options['jobs'])

        self._make(p, maker, name, path)
        self._syncIncludes(name, p)


commands = registerCommands(Make)
Exemplo n.º 9
0
 def _commands(self):
     return registerCommands(Add, List, Remove, Show)
Exemplo n.º 10
0
                       '{space}--erase_missing - удаляет файлы, которых нет в папке назначения'], self.syncWorkspaces,
                      lambda p: Rule(p).empty().delimers()
                                       .notEmpty().options()
                                       .check().optionNamesInSet('workspace', 'path', 'dry', 'erase_missing')
                                       .has().option('workspace')
                                       .size().equals(p.targets, 1))

        return [p, w]

    def syncProjects(self, p: Params):
        projects = self.database.projects()
        for arg in p.targets:
            name = arg.value
            Exist(self.database).project(name)
            project = projects[name]
            Sync(self.database, project, 'dry' in p.options, 'erase_missing' in p.options).print().get()

    def syncWorkspaces(self, p: Params):
        wsName = p.targets[0].value
        Exist(self.database).workspace(wsName)
        ws = self.database.selectone(wsName, Workspace)

        ws.src = ws.path
        if 'path' in p.options:
            ws.name = p.options['path']

        Sync(self.database, ws, 'dry' in p.options, 'erase_missing' in p.options).print().get()


commands = registerCommands(Get)
Exemplo n.º 11
0
    def _info(self):
        return ['{path} - создаёт запись о новом проекте']

    def _rules(self):
        return singleOptionCommand(['{path} название_проекта'], self.process)

    def process(self, p: Params):
        name = p.targets[0].value
        NotExist(self.database).project(name)
        prj = inputProject(name, self.database)
        if prj is not None:
            self.database.update(prj)
            print('Проект {0} добавлен'.format(prj.name))
        else:
            print('Отмена...')


class Project(Command):
    def name(self):
        return 'project'

    def _info(self):
        return ['{path} - команды управления проектами']

    def _commands(self):
        return registerCommands(Add, List, Remove, Show)


commands = registerCommands(Project)
Exemplo n.º 12
0
 def _commands(self):
     return registerCommands(Add, List)
Exemplo n.º 13
0
    def _info(self):
        return ['{path} - создаёт запись о новом рабочем окружении']

    def _rules(self):
        return singleOptionCommand(['{path} рабочее_окружение'], self.process)

    def process(self, p: Params):
        name = p.targets[0].value
        NotExist(self.database).workspace(name)
        ws = workspace.inputWorkspace(name)
        if ws is not None:
            self.database.update(ws)
            print('Рабочее окружение {0} добавлено'.format(ws.name))
        else:
            print('Отмена...')


class Workspace(Command):
    def name(self):
        return 'workspace'

    def _info(self):
        return ['{path} - команды управления рабочими окружениями']

    def _commands(self):
        return registerCommands(Add, List)


commands = registerCommands(Workspace)
Exemplo n.º 14
0
 def _commands(self) -> {}:
     return registerCommands(Yamake)
Exemplo n.º 15
0
        return 'yamake'

    def yamake(self, p: Params):
        name = p.targets[0].value
        Exist(self.database).project(name)
        project: Project = self.database.projects()[name]

        if 'ws' in p.options:
            ws: Workspace = self.database.workspaces()[p.options['ws']]
        else:
            ws: Workspace = self.database.workspaces()[project.workspace]

        self.subcmd(Send).execute([name, f'--ws={ws.name}'])
        self.subcmd(Make).execute(p.argv)


class Build(Command):
    def name(self) -> '':
        return 'build'

    def _info(self):
        return [
            '{path} - составные высокоуровневые команды для упрощения процесса разработки'
        ]

    def _commands(self) -> {}:
        return registerCommands(Yamake)


commands = registerCommands(Build)