コード例 #1
0
def main(args):
    """docstring for main"""
    prj_list = load_project_list(args.projects)

    orig = next((prj for prj in prj_list if prj['name'] == args.orig), None)
    if not orig:
        raise Exception('Project {0} does not exists'.format(args.orig))

    new = next((prj for prj in prj_list if prj['name'] == args.new), None)
    if new:
        raise Exception('Project {0} already exists'.format(args.new))

    path = os.path.abspath(os.path.join(os.curdir, args.new))
    if not os.path.exists(path):
        logging.debug('copy project {0} to {1}'.format(args.orig, path))
        if not args.description:
            description = input('Enter descriptions for this project : ')
        else:
            description = args.description
        os.mkdir(path)
        copy(orig['path'], path)
        call(['chmod', '-R', '775', path])

        with open(args.projects, 'a') as f:
            f.write('[{0}]\n'.format(args.new))
            f.write('path={0}\n'.format(path))
            f.write('description={0}\n\n'.format(description))
    else:
        raise Exception('{0} already exists'.format(path))
コード例 #2
0
def install_plugin_from_git(dut, url, branch, script,
                            waiting=5, timeout=180, commitid=None):
    """
    Clone a git project which include tizen plugins and install the plugins \
            on device.
    This helper function turn on device and turn off device automatically.

    :param device dut: device instance
    :param str url: url for git project
    :param str branch: branch name of the git project
    :param str script: script path to install plugins on device
    :param float waiting: wait time before installing plugins
    :param float timeout: timeout
    :param str commitid: commitid which you want to clone

    .. note:: You have to configure your open-ssh key if you want to use ssh \
            protocol to clone the git project.

    Example:
        >>> from litmus.helper.helper import install_plugin_from_git
        >>> install_plugin_from_git(dut,
                                    url='ssh://{username}@localhost:29418/platform/adaptation/opengl-es-mali-t628'
                                    branch='tizen_3.0'
                                    script='install-set/setup')


    """
    logging.debug('=============Install plugins from git===============')
    logging.debug('plugin git path : {}'.format(url))
    logging.debug('plugin git branch : {}'.format(branch))
    logging.debug('plugin git commitid : {}'
                  .format(commitid if commitid else 'latest'))
    logging.debug('plugin install script : {}'.format(script))
    dut.on()

    tmpdir = next(tempfile._get_candidate_names())

    call('git clone {0} {1} --branch {2}'.format(url, tmpdir, branch),
         shell=True)

    if commitid:
        call('git --git-dir={0}/.git checkout {1}'.format(tmpdir, commitid),
             shell=True)

    call('find ./{0} -exec perl -pi -e "s/sdb\s+(-d\s+)*(root|shell|push|pull)'
         '/sdb -s {1} \\2/g" {{}} \;'.format(tmpdir, dut.get_id()),
         stderr=DEVNULL, shell=True)
    call('find ./{0} -exec perl -pi -e "s/sdb\s+.*reboot.*//g"'
         ' {{}} \;'.format(tmpdir), stderr=DEVNULL, shell=True)

    script_path = '/'.join(script.split('/')[:-1])
    script_name = script.split('/')[-1]

    time.sleep(waiting)

    call('cd {0}/{1} && sh {2}'.format(tmpdir, script_path, script_name),
         shell=True, timeout=timeout)
    shutil.rmtree(tmpdir)

    dut.off()
コード例 #3
0
ファイル: cmd_adhoc.py プロジェクト: tizenpdk/litmus
def main(args):
    """docstring for main"""
    sdb_exist()
    project_path = os.path.abspath(args.project_path)
    sys.path.append(project_path)

    call(['chmod', '-R', '775', project_path])

    import userscript
    userscript.main(project_name='adhoc project',
                    project_path=project_path,
                    param=args.param,
                    workingdir=args.workingdir)
コード例 #4
0
    def sdb_root_on(self):
        """
        Set root mode of device

        Example:
            >>> dut.sdb_root_on()

        """
        logging.debug(
            '=================sdb root on for {}=================='.format(
                self.get_name()))
        call('sdb -s {} root on'.format(self.get_id()).split(), timeout=10)
        time.sleep(0.5)
コード例 #5
0
    def _screenshot_x11(self, filename):
        """docstring for _screenshot_x11"""
        # take a screenshot using xwd
        cmd = 'xwd -root -out /tmp/{}.xwd'.format(filename)
        self.run_cmd(cmd, timeout=20)

        # pull xwd file
        self.pull_file('/tmp/{}.xwd'.format(filename), os.curdir, timeout=20)

        # convert xwd to png and resize it
        call([
            'convert', '{0}.xwd'.format(filename), '-resize', '{0}x{1}'.format(
                self._screen_width, self._screen_height), filename
        ],
             timeout=20)
        call(['rm', '{}.xwd'.format(filename)], timeout=20)
コード例 #6
0
 def off(self, delay=4):
     """docstring for off"""
     super(cuttercleware4, self).off()
     c = self._controlcmd.format(cport=self._cport,
                                 cindex=self._cindex,
                                 on_off=0)
     out = call(c, shell=True, timeout=10)
     time.sleep(delay)
     return not out
コード例 #7
0
    def _attach_sdb(self):
        """docstring for _attach_sdb"""
        # start sdb server if it is not started.
        call('sdb start-server'.split(), timeout=10)

        retry_attempt = 0
        pattern = r'{}.*device.*\t.*'.format(self.get_id())

        while retry_attempt < self._max_attempt_attach_sdb:
            for l in range(self._retrycnt_at_a_time_sdb):
                outs = check_output('sdb devices'.split(), timeout=10)
                logging.debug(outs)
                if find_pattern(pattern, outs):
                    logging.debug('found {}.'.format(self.get_id()))
                    return
                time.sleep(0.2)
            retry_attempt += 1
        else:
            raise Exception('Can\'t find device.')
コード例 #8
0
    def _heimdall(self, filenames, busaddr, devaddr, partition_bin_mappings):
        """docstring for _heimdall"""
        filenames = convert_single_item_to_list(filenames)
        tar_cmd = 'tar xvfz'
        for l in filenames:
            tar_cmd += ' {}'.format(l)
        logging.debug(tar_cmd)
        call(tar_cmd, shell=True, timeout=30)

        heimdall_cmd = 'heimdall flash --usbbus {0}' \
                       ' --usbdevaddr {1}'.format(busaddr, devaddr)
        for key, elem in partition_bin_mappings.items():
            heimdall_cmd += ' --{}'.format(key)
            heimdall_cmd += ' {}'.format(elem)
        logging.debug(heimdall_cmd)

        ret = call(heimdall_cmd, shell=True, timeout=600)
        if ret:
            raise Exception('Heimdall error.')
コード例 #9
0
 def _lthor(self, filenames, busid):
     """docstring for _lthor"""
     cmd = 'lthor --busid={0}'.format(busid)
     filenames = convert_single_item_to_list(filenames)
     for l in filenames:
         cmd += ' {}'.format(l)
     logging.debug(cmd)
     ret = call(cmd, shell=True, timeout=600)
     if ret:
         raise Exception('Thor error.')
コード例 #10
0
ファイル: cmd_imp.py プロジェクト: tizenpdk/litmus
def main(args):
    """docstring for main"""
    prj_list = load_project_list(args.projects)

    project = next((prj for prj in prj_list if prj['name'] == args.project),
                   None)
    if project:
        raise Exception('Project {0} already exists'.format(project['name']))

    if not args.description:
        prj_description = input('Enter project descriptions : ')
    else:
        prj_description = args.description

    if not args.path:
        prj_path = input('Enter Project path : ')
    else:
        prj_path = args.path

    if not prj_path:
        raise Exception('Incorrect path!')

    prj_path = os.path.expanduser(prj_path)

    project = next((prj for prj in prj_list if prj['path'] == prj_path), None)

    if project:
        raise Exception('Project {0} already use this path'.format(
            project['name']))

    if not os.path.exists(os.path.abspath(prj_path)) and\
            not os.path.exists(os.path.abspath(os.path.join(prj_path+'/',
                                                            'userscript.py'))):
        raise Exception(
            'There\'s no litmus project scripts at {0}'.format(prj_path))

    call(['chmod', '-R', '775', prj_path])

    with open(args.projects, 'a') as f:
        f.write('[{0}]\n'.format(args.project))
        f.write('path={0}\n'.format(os.path.abspath(prj_path)))
        f.write('description={0}\n\n'.format(prj_description))
コード例 #11
0
ファイル: cuttersmartpower.py プロジェクト: tizenpdk/litmus
    def off(self, delay=4):
        """docstring for off"""
        super(cuttersmartpower, self).off()

        retry_cnt = 0
        while retry_cnt < self._max_retry_cnt:

            if self.is_on():
                c = self._controlcmd.format(cport=self._cport)
                call(c, shell=True, stderr=subprocess.DEVNULL, timeout=10)

            if not self.is_on():
                time.sleep(delay)
                return True
            else:
                logging.debug('Power off failed. Retry')
                retry_cnt += 1
        else:
            logging.debug('Critical issue on smartpower.')
            time.sleep(delay)
            return False
コード例 #12
0
ファイル: cmd_mk.py プロジェクト: tizenpdk/litmus
def main(args):
    """docstring for main"""
    prj_list = load_project_list(args.projects)

    project = next((prj for prj in prj_list if prj['name'] == args.project),
                   None)
    if project:
        raise Exception('Project {0} already exists'.format(args.project))

    if not args.type:
        dev_type = input('Enter the device type ({}): '.format(
            '/'.join(_dev_types_)))
    else:
        dev_type = args.type

    if dev_type not in _dev_types_:
        raise Exception('Incorrect device type')

    path = os.path.abspath(os.path.join(os.curdir, args.project))
    if not os.path.exists(path):
        if not args.description:
            description = input('Enter descriptions for this project : ')
        else:
            description = args.description
        logging.debug('make a new project : {0}'.format(args.project))
        logging.debug('new project path : {0}'.format(path))
        os.mkdir(path)
        src = os.path.join(os.path.join(litmus.__path__[0], 'templates'),
                           dev_type)
        copy(src, path)
        call(['chmod', '-R', '775', path])

        with open(args.projects, 'a') as f:
            f.write('[{0}]\n'.format(args.project))
            f.write('path={0}\n'.format(path))
            f.write('description={0}\n\n'.format(description))
    else:
        raise Exception('{0} already exists'.format(path))
コード例 #13
0
    def _screenshot_wayland(self, filename):
        """docstring for _screenshot_wayland"""
        # Find all viewable window id
        p_winid = '.*(0x[a-zA-Z0-9]{8})\s+\d+\s+\d+\s+\d+' \
                  '\s+\d+\s+(\d+)\s+(\d+).*[0]{1}\s+\d+\s+[NV]{1}.*'
        winids = find_all_pattern(
            p_winid, self.run_cmd('enlightenment_info -topvwins', timeout=20))
        if winids:
            # Dump windows
            outs = self.run_cmd('cd /tmp; enlightenment_info -dump_topvwins',
                                timeout=20)
            dirn = find_pattern('directory:\s(.*)', outs,
                                groupindex=1).rstrip()

            # Create tempdir and pull dump files
            tmpdir = tempfile.mkdtemp()
            self.pull_file(dirn, tmpdir, timeout=20)

            # If dump does not exist then remove winid from list
            winids = [
                winid for winid in winids
                if os.path.exists(os.path.join(tmpdir, winid[0] + '_0.png'))
            ]

            # Base image
            bg = Image.new('RGB', (self._screen_width, self._screen_height))
            # Merge images
            for winid in reversed(winids):
                try:
                    fg = Image.open(os.path.join(tmpdir, winid[0] + '_0.png'))
                    bg.paste(fg, (int(winid[1]), int(winid[2])), fg)
                except FileNotFoundError:
                    pass
            # Save merged image
            bg.save(filename)
            # Remove tempdir
            call(['rm', '-rf', tmpdir], timeout=10)
コード例 #14
0
ファイル: devicestandalone.py プロジェクト: tizenpdk/litmus
 def start_sdb_server(self):
     """docstring for start_sdb_server"""
     call('sdb start-server', shell=True, timeout=10)
     time.sleep(1)
コード例 #15
0
ファイル: devicestandalone.py プロジェクト: tizenpdk/litmus
 def refresh_sdb_server(self):
     """docstring for refresh_sdb_server"""
     call('sdb kill-server; sdb start-server', shell=True, timeout=10)
     time.sleep(1)