예제 #1
0
파일: Log.py 프로젝트: vancebs/EasyCoding3
 def e(tag: str, msg: str):
     Printer.red_line(Log._make_message(tag, msg))
예제 #2
0
파일: Log.py 프로젝트: vancebs/EasyCoding3
 def i(tag: str, msg: str):
     Printer.green_line(Log._make_message(tag, msg))
예제 #3
0
파일: Log.py 프로젝트: vancebs/EasyCoding3
 def w(tag: str, msg: str):
     Printer.yellow_line(Log._make_message(tag, msg))
예제 #4
0
    def on_run(self, *params) -> bool:
        project_root = os.path.abspath(self.cfg.cfgProjectRootDir)
        project_root_dir = '%s/' % project_root

        # get pwd
        pwd = os.path.abspath(self.pwd())
        if len(params) == 1:
            pwd = os.path.abspath('%s/%s' %
                                  (self.cfg.cfgProjectRootDir, params[0]))
            if not os.path.exists(pwd):
                Printer.red_line('Path to push not exists')
                Printer.red_line('  Path: %s' % pwd)
                self.help()
                return False

        # check pwd
        if not pwd.startswith(project_root_dir):
            Printer.red_line(
                'Current path is not valid. Please enter the dir of repository to push'
            )
            Printer.red_line('  Current path: %s' % pwd)
            Printer.red_line('  Project path: %s' % project_root)
            self.help()
            return False

        # get local path under project root dir
        local_path = pwd.replace(project_root_dir, '')

        # check manifest
        manifest = '%s/.repo/manifest.xml' % project_root
        if not os.path.exists(manifest):
            Printer.red_line('manifest not exists.')
            Printer.red_line('  Path: %s' % manifest)
            self.help()
            return False

        # search in manifest
        remote_path = None
        with open(manifest, 'r') as file:
            for line in file:
                match = self._LINE_PATTERN.fullmatch(line)
                if match is None:
                    continue

                git_remote_path = match[1].strip()
                git_local_path = match[2].strip()

                if git_local_path == local_path:
                    remote_path = git_remote_path
                    break

        # check remote path
        if remote_path is None:
            Printer.red_line('Path not find in manifest.')
            Printer.red_line('  Path: %s' % local_path)
            self.help()
            return False

        # do push
        push_url = '%s/%s.git' % (self.cfg.cfgProjectUrlRepoPush, remote_path)
        head = 'HEAD:refs/for/%s' % self.cfg.cfgProjectBranch
        self.shell('git push %s %s' % (push_url, head))

        return True
예제 #5
0
 def remove(self, path: str):
     if os.path.exists(path):
         self.shell('rm -rf %s' % path)
         Printer.green_line('Removed: %s' % path)
예제 #6
0
파일: dump.py 프로젝트: vancebs/EasyCoding3
    def on_run(self, *params) -> bool:
        Printer.yellow_line('======> dump begin')
        Printer.blue_line('EC')
        Printer.green_line('  Dir: %s' % self.cfg.cfgProgramDir)
        Printer.green_line('  cmd dir: %s' % self.cfg.cfgProgramCmdDir)
        Printer.green_line('  cmd list: %s' % self.cfg.cfgProgramCmdList)
        Printer.green_line('  cfg dir: %s' % self.cfg.cfgProgramCfgDir)
        Printer.green_line('  cfg list: %s' % self.cfg.cfgProgramCfgList)
        Printer.green_line('  cfg file: %s' % self.cfg.cfgProgramCfgFile)
        Printer.blue_line('Global')
        Printer.green_line('  base dir: %s' % self.cfg.cfgGlobalBaseDir)
        Printer.green_line('  pull url: %s' % self.cfg.cfgGlobalUrlRepoPull)
        Printer.green_line('  push url: %s' % self.cfg.cfgGlobalUrlRepoPush)
        Printer.green_line('  user name: %s' % self.cfg.cfgGlobalUserName)
        Printer.green_line('  user email: %s' % self.cfg.cfgGlobalUserEmail)
        Printer.blue_line('Project')
        Printer.green_line('  name: %s' % self.cfg.cfgProjectName)
        Printer.green_line('  branch: %s' % self.cfg.cfgProjectBranch)
        Printer.green_line('  root dir: %s' % self.cfg.cfgProjectRootDir)
        Printer.green_line('  out dir: %s' % self.cfg.cfgProjectOutDir)
        Printer.green_line('  env setup: %s' % self.cfg.cfgProjectEnvSetup)
        Printer.green_line('  env config: %s' % self.cfg.cfgProjectEnvConfig)
        Printer.green_line('  flash map: %s' % self.cfg.cfgProjectFlashMap)
        Printer.green_line('  pull url: %s' % self.cfg.cfgProjectUrlRepoPull)
        Printer.green_line('  push url: %s' % self.cfg.cfgProjectUrlRepoPush)
        Printer.green_line('  repo bin: %s' % self.cfg.cfgProjectRepoBin)
        Printer.yellow_line('<====== dump end')

        return True
예제 #7
0
 def close():
     Printer.green_line('=====> stop shell')
     print('==end==')
예제 #8
0
 def open():
     Printer.green_line('=====> open shell')
예제 #9
0
    def shell(self, argv):
        shell = Shell()
        with shell:
            # ignore program path
            argv = argv[1:]

            # check argv
            if len(argv) <= 0:
                Printer.red_line('No project input!!!')
                self.help()
                return

            # get print flag
            do_print = False
            print_flag = argv[0].strip()
            if print_flag == '--print' or print_flag == '-p':
                do_print = True
                shell.fake_exec(True)
                argv = argv[1:]

            # check argv
            if len(argv) <= 0:
                Printer.red_line('No project input!!!')
                self.help()
                return

            # get project
            project = argv[0].strip() if do_print else print_flag

            # get command
            command = ' '.join(argv[1:]).strip()

            # parser argv
            cmd_list = list(map(str.strip, command.split(',')))

            # env
            env = Env()

            # load cfg
            cfg = env.load_cfg(project)
            if cfg is None:
                Printer.red_line('invalid project: %s' % project)
                Printer.yellow_line('available project: %s' % env.cfgProgramCfgList)
                return

            # check cmd
            cmd_checked = []
            for c in cmd_list:
                cmd_parts = list(map(str.strip, c.split(' ')))
                cmd_name = cmd_parts[0]
                cmd_params = cmd_parts[1:]

                cmd = env.load_cmd(cmd_name)
                if cmd is None:
                    Printer.red_line('invalid command: %s.' % cmd_name)
                    Printer.yellow_line('available cmd: %s' % env.cfgProgramCmdList)
                    return
                else:
                    cmd_checked.append({'cmd': cmd, 'params': cmd_params})

            # run cmd
            for c in cmd_checked:
                c['cmd'].run(shell, cfg, *tuple(c['params']))
예제 #10
0
 def help():
     Printer.yellow_line('ec [--print|-p|-P] <project> CMD1 [PARAM1], [CMD2] [PARAM2]')
     Printer.yellow_line('\t [--print|-p|-P]: print the command instead of execute on shell')