Exemplo n.º 1
0
    def installAdapter(self, name):
        """
        """
        RepoAdapters.initialize(context=None)

        folder_lib = "%s/%s/%s" % (Settings.getDirExec(),
                                   Settings.get('Paths',
                                                'packages-sutadapters'), name)
        folder_lib = os.path.normpath(folder_lib)
        if os.path.exists(folder_lib):
            try:

                # install dependancies according to the plugin with pip
                pip_list = "%s/deps/pip_list.txt" % folder_lib
                pip_list = os.path.normpath(pip_list)
                if os.path.exists(pip_list) and os.path.getsize(pip_list) > 0:
                    if platform.system() == "Windows":
                        cmd = "%s -m pip install -r \"%s\"" % (Settings.get(
                            'Bin', 'python-win'), pip_list)
                    else:
                        cmd = "%s -m pip install -r %s" % (Settings.get(
                            'Bin', 'python'), pip_list)
                    subprocess.call(cmd, shell=True)

                # system detect
                yum_list = "%s/deps/yum_list.txt" % folder_lib
                yum_list = os.path.normpath(yum_list)
                if os.path.exists(yum_list) and os.path.getsize(yum_list) > 0:
                    if os.path.exists("/etc/os-release"):
                        os_id = ""
                        with open("/etc/os-release") as f:
                            for line in f:
                                if "=" in line:
                                    k, v = line.rstrip().split("=")
                                    if k == "ID":
                                        os_id = v.strip('"')
                                        break

                        if "centos" in os_id or "rhel" in os_id:
                            cmd = "yum install `cat %s | tr '\n' ' '`" % yum_list
                            subprocess.call(cmd, shell=True)

                RepoAdapters.instance().updateMainInit()

                # install samples according to the plugin
                if os.path.exists("%s/samples/" % folder_lib):
                    folder_sample = "%s/%s/1/Samples/Adapter_%s" % (
                        Settings.getDirExec(), Settings.get('Paths',
                                                            'tests'), name)
                    shutil.copytree("%s/samples/" % folder_lib, folder_sample)

                print("Sut Adapter installation process terminated")
            except Exception as e:
                print("unable to install adapter: %s" % e)

        else:
            print("Sut Adapter (%s) not found!" % name)

        RepoAdapters.instance().updateMainInit()
Exemplo n.º 2
0
    def reload(self):
        """
        Reload configuration
        Send a signal to the process
        """
        sys.stdout.write("Reloading configuration...\n")
        if not self.parent.status():
            sys.stdout.write("Server not started...\n")
        else:
            pid = self.parent.getPid()
            if pid is not None:
                self.parent.sendSignal(pid, signal.SIGHUP)
                sys.stdout.write("Configuration reloaded!\n")

                RepoAdapters.initialize(context=None)
                RepoAdapters.instance().updateMainInit()
                sys.stdout.write("Adapters reloaded!\n")

        sys.stdout.flush()
def appendTestArgs(taskUuid, userName, userId, projectId, projectName,
                   testName, testLocation, trPath, logFilename, var_path):

    testpath_norm = "%s/%s/" % (RepoTests.instance().testsPath, projectId)
    adapterpath_norm = "%s/" % (RepoAdapters.instance().testsPath)
    full_trpath = "%s/%s/" % (var_path, trPath)

    te = []
    te.append("""taskuuid_ = '%s'\n""" % taskUuid)
    te.append("""user_ = '%s'\n""" % userName)
    te.append("""userid_ = '%s'\n""" % userId)
    te.append("""projectid_ = '%s'\n""" % projectId)
    te.append("""projectname_ = '%s'\n""" % projectName)
    te.append("""test_name = '%s'\n""" % testName)
    te.append("""test_location = '%s'\n""" % testLocation)
    te.append("""test_result_path = r'%s'\n""" % os.path.normpath(trPath))
    te.append("""log_filename = '%s'\n""" % logFilename)
    te.append("""tests_path = r'%s'\n""" % os.path.normpath(testpath_norm))
    te.append("""adapters_path = r'%s'\n""" %
              os.path.normpath(adapterpath_norm))
    te.append("""full_tr_path = r'%s'\n""" % os.path.normpath(full_trpath))
    return te