Esempio n. 1
0
 def get_project_list(self):
     if self.project_cache is None:
         wd = self.app.wd
         self.open_manage_project_page()
         self.project_cache = []
         for row in wd.find_elements_by_class_name("row-1"):
             cells = row.find_elements_by_tag_name("td")
             if len(cells) == 5:
                 project_name = cells[0].text
                 status = cells[1].text
                 view_status = cells[3].text
                 desription = cells[4].text
                 self.project_cache.append(
                     Project(project_name=project_name,
                             status=status,
                             view_status=view_status,
                             description=desription))
         for row in wd.find_elements_by_class_name("row-2"):
             cells = row.find_elements_by_tag_name("td")
             if len(cells) == 5:
                 project_name = cells[0].text
                 status = cells[1].text
                 view_status = cells[3].text
                 desription = cells[4].text
                 self.project_cache.append(
                     Project(project_name=project_name,
                             status=status,
                             view_status=view_status,
                             description=desription))
     return list(self.project_cache)
Esempio n. 2
0
def test_add_project(app):
    username = app.config["webadmin"]["username"]
    password = app.config["webadmin"]["password"]
    projects_list_old = app.soap.get_projects_list(username, password)
    name = random_str()
    app.project.add(Project(name=name))
    projects_list_new = app.soap.get_projects_list(username, password)
    assert app.project.exist(Project(name=name))
    assert (len(projects_list_new) - len(projects_list_old)) == 1
Esempio n. 3
0
def test_create_new_project(app):
    if len(app.projects.get_project_list()) == 0:
        app.group.create_new_group(
            Project(projectname=randomword(), description="description1"))
    app.session.login("administrator", "root")
    old_list = app.soap.get_list_of_the_projects("administrator", "root")
    app.projects.create_new_project(
        Project(projectname=randomword(), description="description1"))
    new_list = app.soap.get_list_of_the_projects("administrator", "root")
    assert len(old_list) + 1 == len(new_list)
    return print(len(old_list) + 1, len(new_list))
 def get_project_list(self):
     wd = self.app.wd
     self.open_project_page()
     project_cache = []
     for row in wd.find_elements_by_css_selector("table.width100 tr.row-1"):
         cells = row.find_elements_by_css_selector("td")
         name = cells[0].text
         project_cache.append(Project(name=name))
     for row in wd.find_elements_by_css_selector("table.width100 tr.row-2"):
         cells = row.find_elements_by_css_selector("td")
         name = cells[0].text
         project_cache.append(Project(name=name))
     return list(project_cache)
Esempio n. 5
0
def test_delete_project(app):
    app.session.login("administrator", "root")
    if len(app.project.get_project_list()) == 0:
        app.project.add_project(Project(name="test777888999"))
    old_project_list = app.project.get_project_list()
    project = random.choice(old_project_list)
    app.project.delete_project_by_name(Project(name=project.name))
    new_project_list = app.project.get_project_list()
    #assert len(old_project_list)-1 == len(new_project_list)
    old_project_list.remove(project)
    #assert sorted(old_project_list, key=(lambda x: x.name)) == sorted(new_project_list, key=(lambda x: x.name))
    assert sorted(old_project_list, key=(lambda x: x.name)) == sorted(
        app.soap.get_projects_list("administrator", "root"), key=(lambda x: x.name))
    app.session.logout()
def test_add_project(app):
    #app.session.login("administrator", "root")
    username = app.config['webadmin']['username']
    password = app.config['webadmin']['password']
    old_projects = app.soap.get_project_list(username, password)
    new_project = Project(name="myprojectred",
                          description="gawgjkawgjoawgioawgjkaknkgwgwg")
    while app.project.project_is_in_list(prj=new_project,
                                         prj_list=old_projects):
        new_project = Project(name=str(datetime.now()),
                              description="gawgjkawgjoawgioawgjkaknkgwgwg")
    old_projects.append(new_project)
    app.project.create_project(new_project)
    new_projects = app.soap.get_project_list(username, password)
    assert len(old_projects) == len(new_projects)
    def get_project_list(self):
        wd = self.app.wd
        self.open_manager_project_page()
        for element in wd.find_elements_by_css_selector(
                'table.hide td.login-info-right'):
            element.find_element_by_tag_name("form").click()
            projects = element.find_element_by_name('project_id').text
            list = projects.split('\n')
            list.remove('All Projects')
            #return list

        if self.projects_cache is None:
            wd = self.app.wd
            self.open_manager_project_page()
            self.projects_cache = []
            for row in wd.find_elements_by_xpath("//table[3]/tbody/tr")[
                    2:]:  # first two rows are not Projects
                cells = row.find_elements_by_tag_name("td")
                link = row.find_element_by_css_selector("a").get_attribute(
                    'href')
                id = link[link.find("=") + 1:]
                name = cells[0].text
                status = cells[1].text
                enabled = cells[2].text
                viewstatus = cells[3].text
                description = cells[4].text
                scanned_project = Project(id=id,
                                          name=name,
                                          status=status,
                                          enabled=enabled,
                                          viewstatus=viewstatus,
                                          description=description)
                self.projects_cache.append(scanned_project)
        return list(self.projects_cache)
Esempio n. 8
0
    def accept(self):
        rom_path = self.rom_field.text()
        project_path = self.project_path_field.text()
        game = self.game_box.currentIndex()
        language = self.language_box.currentIndex()

        try:
            self.project = Project(rom_path, project_path, game, language)
        except NotADirectoryError:
            logging.exception("Error during project creation.")
            self.message_dialog.showMessage(
                "One of the specified paths is not a directory.", "error")
        except IndexError:
            logging.exception("Error during project creation.")
            self.message_dialog.showMessage("Invalid game or language.",
                                            "error")
        except NotImplementedError:
            logging.exception("Error during project creation.")
            self.message_dialog.showMessage(
                "Attempted to create a project for an unsupported game.")
        except:
            logging.exception("Unknown error during project creation.")
            self.message_dialog.showMessage(
                "An unknown error occurred during project creation.")

        if self.project:
            super().accept()
Esempio n. 9
0
 def get_projects_list(self):
     if self.projects_cache is None:
         wd = self.app.wd
         self.open_projects_page()
         self.projects_cache = []
         elements = wd.find_elements_by_xpath(
             "//tr[contains(@class, 'row-')]")
         for i in range(1, len(elements) - 2):
             name = elements[i].find_element_by_xpath(
                 "td[1]/a").get_attribute("innerText")
             status = elements[i].find_element_by_xpath("td[2]").text
             inherit = elements[i].find_element_by_xpath("td[3]").text
             view_status = elements[i].find_element_by_xpath("td[4]").text
             description = elements[i].find_element_by_xpath("td[5]").text
             link = elements[i].find_element_by_xpath(
                 "td[1]/a").get_attribute("href")
             pid = re.sub('.*manage_proj_edit_page.php.project_id=', "",
                          link)
             self.projects_cache.append(
                 Project(pid=pid,
                         name=name,
                         status=status,
                         inherit=inherit,
                         view_status=view_status,
                         description=description))
     return list(self.projects_cache)
Esempio n. 10
0
def add_sample_projects(session, username):
    for project_data in projects_data:
        name = truncate(project_data['name'], 40)
        description = truncate(project_data['description'], 90)
        project = Project(name=name, description=description, owner=username)
        issues = project_data['issues']
        count = len(issues)
        counter = Counter()
        for (i, issue_data) in enumerate(issues):
            title = truncate(issue_data['title'], 40)
            description = truncate(issue_data['description'], 90)

            if i < count * .1:
                status = 3
            elif i < count * .3:
                status = 2
            elif i < count * .6:
                status = 1
            else:
                status = 0

            index = counter[status]
            counter[status] += 1

            issue = Issue(title=title, description=description, project=project, type=get_type(), assignee='',
                          storypoints=get_storypoints(), status=status, priority=get_priority(), index=index)
            session.add(issue)
        session.add(project)
    session.commit()
Esempio n. 11
0
def test_add_empty_project(app):
    app.open_project_page()
    app.login(username="******", password="******")
    app.open_project()
    app.create_project(Project(name="", description=""))
    app.return_project_page()
    app.logout()
 def __init__(self,
              t_callback,
              c_callback,
              pcl_callback,
              verbose,
              comm_mode,
              serial_port,
              serial_baud,
              RS485_ID,
              ip,
              detail_target_enable,
              wifi_port=8877):
     self.receiver = None
     self.clients = None
     self.project = Project()
     self.project.work_mode = comm_mode  # MODE_485=0 or MODE_WIFI=1
     self.project.serial_com = serial_port  # initialize this variable even if using WiFi
     self.project.serial_baud = serial_baud
     if detail_target_enable == 1:
         self.project.detail_target = True
     else:
         self.project.detail_target = False
     self.t_callback_fcn = t_callback
     self.c_callback_fcn = c_callback
     self.pcl_callback_fcn = pcl_callback
     self.id_485 = str(RS485_ID)
     self.ip = ip
     self.project.wifi_server_port = wifi_port
     self.verbose = verbose
     self.radars = {}  # this is a dictionary of Wayv_Air_Radar objects
     ver = api_version()
     self.version = ver.version
Esempio n. 13
0
 def get_project_list(self):
     if self.project_cache is None:
         wd = self.app.wd
         self.open_project_page()
         self.project_cache = []
         for row in wd.find_element_by_xpath(
                 "/html/body/table[3]/tbody").find_elements_by_tag_name(
                     "tr"):
             if row != wd.find_element_by_xpath("/html/body/table[3]/tbody").find_elements_by_tag_name("tr")[0] and \
                     row != wd.find_element_by_xpath("/html/body/table[3]/tbody").find_elements_by_tag_name("tr")[1]:
                 td = row.find_elements_by_tag_name("td")
                 name = td[0].find_element_by_tag_name("a").text
                 status = td[1].text
                 view_ststus = td[3].text
                 description = td[4].text
                 url = td[0].find_element_by_tag_name("a").get_attribute(
                     "href")
                 parsed = urlparse.urlparse(url)
                 id = urlparse.parse_qs(parsed.query)['project_id'][0]
                 self.project_cache.append(
                     Project(project_name=name,
                             status=status,
                             view_status=view_ststus,
                             description=description,
                             id=id))
     return list(self.project_cache)
Esempio n. 14
0
 def get_project_list(self):
     if self.project_cache is None:
         wd = self.app.wd
         self.open_projects_page()
         self.project_cache = []
         for row in wd.find_elements_by_xpath(
                 "//a[contains(@href, 'manage_proj_edit_page.php?project_id=')]/../.."
         ):
             cells = row.find_elements_by_tag_name("td")
             id = re.sub(
                 ".*=", "", cells[0].find_element_by_css_selector(
                     'a').get_attribute('href'))
             name = cells[0].text
             status = cells[1].text
             if cells[2].text == 'X':
                 enabled = True
             else:
                 enabled = False
             view_status = cells[3].text
             description = cells[4].text
             self.project_cache.append(
                 Project(id=id,
                         name=name,
                         status=status,
                         enabled=enabled,
                         view_status=view_status,
                         description=description))
     return list(self.project_cache)
Esempio n. 15
0
    def post(self, project):
        """
        Uploads an image to the project training set.
        Images are uploaded as mutli-part \"images\" form
        element
        """
        if not project in projects:
            pr = get_project(project)
            projects[project] = Project(project, pr)
            if pr is None:
                return 'Project not found.', 404
        p = projects[project]
        fl = request.files['images']
        image_name = fl.filename.replace(',', '_')
        fn = secure_filename(p.tempdir + image_name)
        try:
            fl.save(fn)
            im = Image.open(fn)
            if not im.format == 'JPEG':
                im = im.convert("RGB")
                im.save(fn + '.jpg')
                os.remove(fn)
                fn = fn + '.jpg'

            ofn = "projects/{}/{}{}".format(p.id, image_name,
                                            settings.data["image_type"])
            with open(fn, 'rb') as file_t:
                blob_data = bytearray(file_t.read())
                settings.storage.upload_data(blob_data,
                                             ofn,
                                             contentType='image/jpeg')
                logging.info("uploaded {}".format(ofn))
        finally:
            os.remove(fn)
        return {'msg': 'Image uploaded'}, 200
Esempio n. 16
0
    def get_project_list(self):
        self.open_project_page()
        if self.project_cache is None:
            wd = self.app.wd
            self.project_cache = []
            for element in wd.find_elements_by_xpath(
                    "//div[@class='table-responsive' and position()=2]/table/tbody/tr"
            ):
                cells = element.find_elements_by_tag_name("td")
                a_name = cells[0].find_element_by_tag_name("a")
                project_id = a_name.get_attribute('href').split("=")[1]
                name = a_name.text
                status = cells[1].text
                description = cells[4].text

                try:
                    i_enabled = cells[2].find_element_by_tag_name("i")
                    enabled = i_enabled is not None
                except NoSuchElementException:
                    enabled = False

                self.project_cache.append(
                    Project(name=name,
                            status=status,
                            enabled=enabled,
                            description=description,
                            project_id=project_id))
        return list(self.project_cache)
Esempio n. 17
0
 def get_projects_list(self):
     if self.project_cache is None:
         self.open_projects_page()
         self.project_cache = []
         table_rows = self.app.wd.find_elements_by_css_selector(
             ".width100 tr[class*='row-']")
         del table_rows[0]
         for element in table_rows:
             project_name = element.find_element_by_css_selector(
                 "td:nth-child(1) > a").text
             status = element.find_element_by_css_selector(
                 "td:nth-child(2)").text
             enabled = element.find_element_by_css_selector(
                 "td:nth-child(3)").text == "X"
             view_status = element.find_element_by_css_selector(
                 "td:nth-child(4)").text
             description = element.find_element_by_css_selector(
                 "td:nth-child(5)").text
             self.project_cache.append(
                 Project(project_name=project_name,
                         status=status,
                         enabled=enabled,
                         view_status=view_status,
                         description=description))
     return list(self.project_cache)
    def get_projects_list(self):
        if self.project_cache is None:
            wd = self.app.wd
            self.open_projects_management_page()
            self.project_cache = []

            elements = wd.find_elements_by_xpath(
                "/html/body/table[3]/tbody/tr")[2:]

            for element in elements:
                columns = element.find_elements_by_xpath(".//td")
                name = columns[0].find_element_by_xpath(".//a").text
                link = columns[0].find_element_by_xpath(".//a").get_attribute(
                    'href')
                id = link[link.find("=") + 1:]
                status = columns[1].text
                view_status = columns[3].text
                description = columns[4].text
                self.project_cache.append(
                    Project(name=name,
                            status=status,
                            view_status=view_status,
                            description=description,
                            id=id))
        return list(self.project_cache)
Esempio n. 19
0
 def get_project_list(self):
     project_list = []
     status_list = {
         10: "development",
         30: "release",
         50: "stable",
         70: "obsolete",
     }
     view_state_list = {10: "public", 50: "private"}
     cursor = self.connection.cursor()
     try:
         cursor.execute(
             "SELECT id, name, status, view_state, description FROM mantis_project_table"
         )
         for row in cursor:
             (id, name, status_num, view_state_num, description) = row
             project_list.append(
                 Project(id=id,
                         name=name,
                         status=status_list[status_num],
                         view_state=view_state_list[view_state_num],
                         description=description))
     finally:
         cursor.close()
     return project_list
Esempio n. 20
0
 def get(self, cam, project):
     """
     Takes a snapshot and uploads it to the bucket/project_folder/predictions/ and
     returns a json document with the prediction info.
     * coords = relative coordinates of the capture at a percentage of image
     * image = Image name
     * path = Path to the image in the bucket
     * tags = Predition probability for each tag
     ```
     {
         "coords":{
             "c2_good":[0.209846, 0.0299885, 1, 0.637807],
             "emmc_good":[0.344515, 0.593382, 0.500586, 0.694372],
             "hdmi_good":[0.315496, 0.896179, 0.623717, 0.960438],
             "rpi3_cpu_good":[0.155855, 0.417758, 0.295672, 0.517903]
         },
         "image": "92b7245f-970a-4ec5-8fd5-4377b809ec07.jpg",
         "path": "project0/predictions/92b7245f-970a-4ec5-8fd5-4377b809ec07.jpg",
         "tags":{
             "c2_good": 0.422927,
             "emmc_good": 0.640976,
             "hdmi_good": 0.432281,
             "num_detections": "9",
             "rpi3_cpu_good": 0.535758
         }
     }
     ```
     """
     if not project in projects:
         pr = get_project(project)
         projects[project] = Project(project, pr)
         if pr is None:
             return 'Project not found.', 404
     p = projects[project]
     image_name = uuid.uuid4()
     img, tags, detections, ppmm = settings.camera.get_picture(cam,
                                                               predict=True,
                                                               project=p)
     ofn = "projects/{}/predictions/images/{}{}".format(
         p.id, image_name, settings.data["image_type"])
     dfn = "projects/{}/predictions/data/{}{}".format(
         p.id, image_name, 'json')
     p.s3.put_object(Body=img.tobytes(),
                     Bucket=p.bucket,
                     Key=ofn,
                     ContentType='image/jpeg')
     resp_obj = {
         "image": str(image_name) + settings.data["image_type"],
         "path": ofn,
         'tags': tags,
         'detections': detections,
         'ppmm': ppmm,
         'model': p.model,
         'model_version': p.version
     }
     p.s3.put_object(Body=json.dumps(resp_obj),
                     Bucket=p.bucket,
                     Key=dfn,
                     ContentType='application/json')
     return jsonify(resp_obj)
Esempio n. 21
0
 def find_selector(self, cclass):
     driver = self.app.driver
     for element in driver.find_elements_by_css_selector(cclass):
         if element.find_element_by_tag_name('a'):
             href = element.find_element_by_tag_name('a').get_attribute(
                 'href')
             self.project_cache.append(Project(path=href[33:]))
Esempio n. 22
0
def test_load_list_project(app):
    app.open_projects_page()
    old_projects = app.project.get_project_list()
    app.project.create(
        Project(name="new_project_1", description="description_project_1"))
    new_projects = app.project.get_project_list()
    assert len(old_projects) + 1 == len(new_projects)
Esempio n. 23
0
 def get_list(self):
     wd = self.app.wd
     if self.project_cache is None:
         self.open_manage_page()
         self.project_cache = []
         elements = wd.find_elements_by_css_selector(
             "table.width100 tr.row-1")
         elements += wd.find_elements_by_css_selector(
             "table.width100 tr.row-2")
         for element in elements:
             graphs = element.find_elements_by_tag_name('td')
             name = graphs[0].text
             status = graphs[1].text
             view_state = graphs[3].text
             description = graphs[4].text
             id_link = wd.find_element_by_link_text(name).get_attribute(
                 "href")
             id_index = id_link.index('=') + 1
             id = id_link[id_index:]
             self.project_cache.append(
                 Project(id=id,
                         name=name,
                         status=status,
                         view_state=view_state,
                         description=description))
     return list(self.project_cache)
def test_add_project(app):
    #username = app.config['webadmin']["username"]
    #password = app.config['webadmin']["password"]
    app.session.ensure_login(app.username, app.password)
    name_list = app.projects.get_project_name_list()
    name = random_string("pr_", 10)
    while name in name_list:
        name = random_string("pr_", 10)
    #    print(name +" - name changed")
    #print(name_list)
    #print(name)
    status = random.choice(["development", "release", "stable", "obsolete"])
    view_state = random.choice(["public", "private"])
    #print(status)
    #print(view_state)
    project_to_add = Project(name=name,
                             status=status,
                             view_state=view_state,
                             description=random_string("", 10))
    soap_proj_list_old = app.soap.get_soap_project_list(
        app.username, app.password)
    app.projects.create_project(project_to_add)
    new_name_list = app.projects.get_project_name_list()
    assert len(name_list) + 1 == len(new_name_list)
    name_list.append(project_to_add.name)
    #print(sorted(name_list))
    #print(sorted(new_name_list))
    assert sorted(name_list) == sorted(new_name_list)
    soap_proj_list_new = app.soap.get_soap_project_list(
        app.username, app.password)
    #assert len(soap_proj_list_old)+1 == len(soap_proj_list_new)
    soap_proj_list_old.append(project_to_add.name)
    assert sorted(soap_proj_list_old) == sorted(soap_proj_list_new)
Esempio n. 25
0
def test_delete_some_project(app, db, check_ui, config):
    if len(db.get_project_list()) == 0:
        app.group.create(
            Project(name='Test' + str(randint(1, 100000)),
                    description='description' + str(randint(1, 100000))))
    old_projects = app.soap.get_project_list(
        username=config['web']["username"],
        password=config['web']["password"],
        baseURL=config['web']['baseURL'])
    project = random.choice(old_projects)
    app.project.delete_project_by_id(project.identifier)
    new_projects = app.soap.get_project_list(
        username=config['web']["username"],
        password=config['web']["password"],
        baseURL=config['web']['baseURL'])
    old_projects.remove(project)
    assert old_projects == new_projects

    def clean(cleaning_project):
        return Project(identifier=cleaning_project.identifier,
                       name=cleaning_project.name.strip(),
                       description=cleaning_project.description.strip())

    if check_ui:
        clean_new_projects = map(clean, new_projects)
        assert sorted(clean_new_projects, key=Project.id_or_max) == sorted(
            app.project.get_project_list(), key=Project.id_or_max)
Esempio n. 26
0
    def mc_projects_get_user_accessible(self, soapuser, soappass):
        client = Client(
            "http://localhost/mantisbt-2.20.0/api/soap/mantisconnect.php?wsdl")
        proj_list = []
        dict = {}
        #dict = client.service.mc_projects_get_user_accessible(soapuser, soappass)

        try:

            for row in (client.service.mc_projects_get_user_accessible(
                    soapuser, soappass)):
                id = row.id
                name = row.name
                status = (row.status.id, row.status.name)
                access_min = (row.access_min.id, row.access_min.name)
                file_path = row.file_path
                description = row.description
                subprojects = [row.subprojects]
                #row.enabled, (row.view_state.id), row.view_state.name), (str(row.access_min.id), row.access_min.name), row.file_path, row.description, row.subprojects
                proj_list.append(
                    Project(id=str(id),
                            name=str(name),
                            description=str(description)))
                #print(proj_list)

            #   id = row.get('id')
            #  name = row.get('name')
            # proj_list.append(Project(id=str(id), name=name))
            return proj_list

        except WebFault:
            return False
def test_create_project(app):
    app.project.open_projects_page()
    before_add_project = app.project.count()
    admin_config = app.config['admin']
    project_to_create = Project(name=random_string(5))
    while app.soap.project_exists(admin_config['username'], admin_config['password'], project_to_create.name):
        project_to_create = Project(name=random_string(5))

    # projects = app.project.get_projects_list()
    # project_to_create = Project(name=random_string(5))
    # if project_to_create in projects:
    #     project_to_create = Project(name=random_string(5))

    app.project.create(project_to_create)
    after_add_project = app.project.count()
    assert after_add_project - before_add_project == 1
Esempio n. 28
0
 def get_projects_list(self, username, password):
     project_list = []
     client = Client("http://localhost/mantisbt-1.2.20/api/soap/mantisconnect.php?wsdl")
     projects = list(client.service.mc_projects_get_user_accessible(username, password))
     for ProjectData in projects:
         project_list.append(Project(name=ProjectData.name))
     return list(project_list)
def test_delete_project(app, number):

    old_projects_list = app.project.get_projects_list()
    if len(old_projects_list) == 0:
        app.project.create(
            Project(name="Inherit None private stable 6",
                    status="stable",
                    view_status="private",
                    inherit=False,
                    description="Test description"))
        old_projects_list = app.project.get_projects_list()
    print(old_projects_list)
    print("Len %s" % str(len(old_projects_list)))

    project_to_delete = choice(old_projects_list)
    app.project.delete_by_pid(project_to_delete.pid)

    new_projects_list = app.project.get_projects_list()
    print(new_projects_list)
    print("Len %s" % str(len(new_projects_list)))

    old_projects_list.remove(project_to_delete)

    old_projects_list_cleaned = [p.clean_project() for p in old_projects_list]
    new_projects_list_cleaned = [p.clean_project() for p in new_projects_list]

    assert sorted(new_projects_list_cleaned, key=lambda p: p.pid_or_max()) == \
           sorted(old_projects_list_cleaned, key=lambda p: p.pid_or_max())
Esempio n. 30
0
def convert_soap_to_model(soap_proj):
    return Project(id=soap_proj.id,
                   name=soap_proj.name,
                   status=soap_proj.status.name,
                   enabled=soap_proj.enabled,
                   view=soap_proj.view_state.name,
                   description=soap_proj.description)