Example #1
0
def process_comments(bug_id,jira,issue):
    comments = utilities.getResultSetWith(queries.get_comments,bug_id)
    i = 0
    descr = None
    for com in comments:
            cmnt =  comment(com[0])
            cmnt.who = com[1]
            cmnt.add_date(com[2])
            cmnt.text = com[3]
            cmnt.is_private = com[4]
            cmnt.attach = com[5]
            if(i<1):
                descr = cmnt.text
                continue
            user_id = utilities.get_user(cmnt.who,jira)
            final_comment= "Originally commented by [~"+user_id+"] on "+ cmnt.c_date +".\n\n"+cmnt.text
            if(cmnt.attach is not None):
                result = utilities.getQueryResultWith(queries.get_attachs,cmnt.attach)
                if(result is not None):
                    content = utilities.getQueryResultWith(queries.attach_content,cmnt.attach)
                    #content, filename = attachment.get_attachment(cmnt.attach)
                    final_comment = "Originally attached by [~"+user_id+"] on "+ cmnt.c_date+".\n [^"+result[0]+"] \n"+result[1] +"\n\n"
                    jira.add_attachment(issue=issue, attachment=content[0], filename=result[0])
                else:
                    continue
            jira.add_comment(issue, final_comment)
            i+=1
    return descr
Example #2
0
 def get(self):
     self.response.headers['Content-Type'] = 'text/html'
     template_values = {
         'user': utilities.get_user(),
         'anagrams': utilities.getanagrams_from_user(utilities.getuser())
     }
     template = JINJA_ENVIRONMENT.get_template('/html/AddWord.html')
     self.response.write(template.render(template_values))
Example #3
0
def render_main(self, url, anagrams):
    template_values = {
        'url': url,
        'user': utilities.get_user(),
        'anagrams': anagrams,
    }

    template = JINJA_ENVIRONMENT.get_template('/templates/main.html')
    self.response.write(template.render(template_values))
Example #4
0
def render_search(self, search_term, search_result):
    template_search_values = {
        'user': utilities.get_user(),
        'search_term': search_term,
        'search_result': search_result,
    }

    template = JINJA_ENVIRONMENT.get_template('/html/searchResult.html')
    self.response.write(template.render(template_search_values))
Example #5
0
def render_subanagram(self, url, value, anagrams):
    template_search_values = {
        'url': url,
        'user': utilities.get_user(),
        'value': value,
        'anagrams': anagrams,
    }

    template = JINJA_ENVIRONMENT.get_template('/templates/subanagram.html')
    self.response.write(template.render(template_search_values))
Example #6
0
def render_main(self, url, anagrams, wordCount,totalCount):
    template_values = {
        'url': url,
        'user': utilities.get_user(),
        'anagrams': anagrams,
        'wordCount': wordCount,
        'totalCount': totalCount
    }

    template = JINJA_ENVIRONMENT.get_template('/html/main.html')
    self.response.write(template.render(template_values))
 def get(self):
     self.response.headers['Content-Type'] = 'text/html'
     if utilities.user_loggedin():
         if not utilities.existing_user():
             utilities.add_new_user(utilities.get_user())
         result, wordCount, totalCount = utilities.getanagrams_from_user(
             utilities.getuser())
         renderer.render_main(self, utilities.getlogouturl(self), result,
                              wordCount, totalCount)
     # If user is not logged in create login url
     else:
         renderer.render_login(self, utilities.getloginurl(self))
Example #8
0
    def get(self):
        logging.debug("GET")
        self.response.headers['Content-Type'] = 'text/html'

        if utilities.user_is_logged_in():
            if not utilities.user_exists():
                utilities.add_new_user(utilities.get_user())

            renderer.render_addanagram(self, utilities.get_logout_url(self),
                                 utilities.get_anagrams_of_user(utilities.get_my_user()))

        else:
            renderer.render_login(self, utilities.get_login_url(self))
Example #9
0
def render_main(self, url, directories, files, current_path, is_in_root, upload_url):
    template_values = {
        'url': url,
        'user': utilities.get_user(),
        'directories': directories,
        'files': files,
        'current_path': current_path,
        'is_not_in_root': not is_in_root,
        'upload_url': upload_url
    }

    template = JINJA_ENVIRONMENT.get_template('/templates/main.html')
    self.response.write(template.render(template_values))
Example #10
0
def groom_api_log(page=1):
    level, _, _ = util.get_user(app)
    if level < 1:
        return util.json(403, 'Not authorized')

    attempts = Attempt.query.order_by(Attempt.time.desc()).paginate(page, 10)
    keys = Attempt.__table__.columns.keys()
    m = map(lambda a: {k: getattr(a, k) for k in keys}, attempts.items)
    response = fk.json.jsonify(ok=True,
                               attempts=list(m),
                               prev=attempts.has_prev,
                               next=attempts.has_next)

    return response
Example #11
0
    def get(self):
        self.response.headers['Content-Type'] = 'text/html'

        if utilities.user_is_logged_in():

            if not utilities.user_exists():
                utilities.add_new_user(utilities.get_user())
            result, wordCount, totalCount = utilities.get_anagrams_of_user(
                utilities.get_my_user())
            renderer.render_main(self, utilities.get_logout_url(self), result,
                                 wordCount, totalCount)

        else:
            renderer.render_login(self, utilities.get_login_url(self))
Example #12
0
 def get(self):
     self.response.headers['Content-Type'] = 'text/html'
     # Check whether user is logged in
     if utilities.user_loggedin():
         # if myuser object is None --> No user with key found --> new user --> make new user in datastore
         if not utilities.existing_user():
             utilities.addnewuser(utilities.get_user())
         result, wordCount, totalCount = utilities.getanagrams_from_user(
             utilities.getuser())
         renderer.render_main(self, utilities.getlogouturl(self), result,
                              wordCount, totalCount)
     # If no user is logged in create login url
     else:
         renderer.render_login(self, utilities.getloginurl(self))
Example #13
0
    def get(self):
        logging.debug("GET")
        self.response.headers['Content-Type'] = 'text/html'

        if utilities.user_is_logged_in():
            # if myuser object is None --> No user with key found --> new user --> make new user in datastore
            if not utilities.user_exists():
                utilities.add_new_user(utilities.get_user())

            renderer.render_subanagram(
                self, utilities.get_logout_url(self), self.request.get('name'),
                utilities.get_anagrams_of_user(utilities.get_my_user()))

        # if no user is logged in create login url
        else:
            renderer.render_login(self, utilities.get_login_url(self))
    def get(self):
        logging.debug("GET")
        self.response.headers['Content-Type'] = 'text/html'

        if utilities.user_is_logged_in():
            if not utilities.user_exists():
                utilities.add_new_user(utilities.get_user())

            renderer.render_searchtext(
                self, utilities.get_logout_url(self),
                utilities.generate_id(self.request.get('value')),
                utilities.prepare_text_input(self.request.get('value')),
                utilities.get_anagrams_of_user(utilities.get_my_user()))

        else:
            renderer.render_login(self, utilities.get_login_url(self))
Example #15
0
def groom_api_open():
    level, mail, _ = util.get_user(app)

    if level < 0 or not mail:
        util.log_attempt(app, mail, 'unauthorized')
        return util.json(403 if mail else 401, 'Not authorized')

    try:
        print('Contacting the groom service...')
        with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
            sock.connect((app.config['GROOM_HOST'], app.config['GROOM_PORT']))
            sock.sendall(b'UNLOCK\n')
            if sock.recv(12) == b'UNLOCK START':
                util.log_attempt(app, mail, 'granted')
                return util.json(200, 'Door opened')
            else:
                raise ValueError('Protocol Error')
    except Exception:
        util.log_attempt(app, mail, 'protocol-error')
        return util.json(500, 'Protocol error while interacting with groom')

    return util.json(200, 'Door opened')
Example #16
0
    def get(self):
        logging.debug('GET')
        self.response.headers['Content-Type'] = 'text/html'

        # check whether user is logged in
        if utilities.is_user_logged_in():
            # if myuser object is None --> No user with key found --> new user --> make new user in datastore
            if not utilities.user_exists():
                utilities.add_new_user(utilities.get_user())

            self.navigate()

            # get all directories and files in the current path
            directories_in_current_path = utilities.get_directories_in_current_path()
            files_in_current_path = utilities.get_files_in_current_path()

            # sort all directories and files alphabetically
            directories_in_current_path = utilities.sort_list(directories_in_current_path)
            files_in_current_path = utilities.sort_list(files_in_current_path)

            # extract file and directory names from the key list
            # so that only the names have to be send to the gui and not the whole object
            directories_in_current_path = utilities.get_names_from_list(directories_in_current_path)
            files_in_current_path = utilities.get_names_from_list(files_in_current_path)

            renderer.render_main(self,
                                 utilities.get_logout_url(self),
                                 directories_in_current_path,
                                 files_in_current_path,
                                 utilities.get_current_directory_object().path,
                                 utilities.is_in_root_directory(),
                                 blobstore.create_upload_url('/upload'))

        # if no user is logged in create login url
        else:
            renderer.render_login(self, utilities.get_login_url(self))
Example #17
0
def process_columns(record,jira,df,file,j):
    global jira_issue,exception,type,create_status,update_status,comment_status,attachment_status
    project_name = utilities.readProperty("Projects", "Destination_Project")
    #assignee  = utilities.getQueryResult(queries.assignee_name)
    #project_name = utilities.getQueryResultWith(queries.project_name)
    summary = record.summary
    #component = utilities.getQueryResultWith(queries.component_name,record.component_id)
    jira_obj = jira_record(summary)
    jira_obj.assignee = utilities.get_user(record.assigned_to,jira)
    jira_obj.components = components_result[record.component_id]
    #jira_obj.user_name = utilities.assignee_result[record.assigned_to]
    jira_obj.bug_severity = jira_obj.process_severity(record.bug_severity,default_values[0])
    jira_obj.status = record.bug_status
    jira_obj.priority = jira_obj.process_priority(record.priority,default_values[1])
    jira_obj.creation_ts = record.creation_ts.isoformat()
    jira_obj.product_id = record.product_id
    #jira_obj.component_id = record.component_id
    jira_obj.resolution = record.resolution
         
    jira_obj.phase_of_detection = jira_obj.process_record_validation(record.cf_client_phase,default_values[2])
    jira_obj.fix_version =   jira_obj.process_record_validation(record.cf_fixes_available,default_values[3])   
    jira_obj.test_engineer = default_users[2]
    jira_obj.issue_type = jira_obj.process_issue_type(record.cf_type,default_values[4])
    jira_obj.test_caseid = record.cf_testcaseid        
    jira_obj.build = record.cf_build
    if(record.estimated_time!=None and record.estimated_time!=0.0):
        jira_obj.estimated_time = utilities.formattime(record.estimated_time*60)
        #since estimated_time is in hours and arguments(arguments for formattime) is in minutes so multiplied by 60
    else:
        jira_obj.estimated_time = record.estimated_time
    if(record.remaining_time != None and record.remaining_time!=0.0):
        jira_obj.remaining_estimate = utilities.formattime(record.remaining_time*60)
        #since estimated_time is in hours and arguments(arguments for formattime) is in minutes so multiplied by 60
    else:
        jira_obj.remaining_estimate = record.remaining_time
    if(record.deadline!=None):    
        jira_obj.deadline =datetime.strptime(record.deadline, '%Y-%m-%d %H:%M:%S.%f').date()
        
    jira_obj.browser = jira_obj.process_browser(record.cf_browser,default_values[5])     
    jira_obj.os = jira_obj.process_os(record.op_sys,default_values[6])
    jira_obj.estimated_time = str(jira_obj.estimated_time)
    jira_obj.remaining_estimate = str(jira_obj.remaining_estimate)
    #converting remaining and estimated time to str because it is showing error 'Object of type 'Decimal' is not JSON serializable' 
    issue_dict = {
          "project": {"key": project_name},
          "summary": summary,
          "description": summary,
          "issuetype": {"name": jira_obj.issue_type},
          "customfield_10513": jira_obj.test_caseid,
          "components": [{"name": jira_obj.components}],
          "customfield_10503" : {"value": jira_obj.phase_of_detection},
          "versions": [{"name": "Wave 1"}],
          "priority":{"name": jira_obj.priority},
          "customfield_10300" : {"value": jira_obj.bug_severity},
          "customfield_10601": {"value": default_users[0]}  
            }
    update_issue = {
            #"aggregatetimeoriginalestimate" : {"value": jira_obj.estimated_time},
            #"timeestimate" : jira_obj.remaining_estimate,
            #"duedate" :{"name" : jira_obj.due_date}
            #"assignee" : {"name" : jira_obj.assignee }
            #"customfield_1020" : {"name" : jira_obj.browser},
            #"customfield_10601" : {"name" : jira_obj.test_engineer },
            #"customfield_16233" : {"name" : jira_obj.status},
            #"resolution" : {"name" : jira_obj.resolution}
            #"customfield_10512": {"value" : jira_obj.build}
            "timeoriginalestimate" : {"value" : jira_obj.estimated_time},
            #"duedate" :{"value" : jira_obj.due_date}
            }
    #new_issue = jira.create_issue(fields=issue_dict)
    new_issue = jira.issue('TPFWD-2')
    #transitions = jira.transitions(new_issue)
    #new_issue.update(update)
    #description = process_comments(record.bug_id,jira,new_issue)
    print("fields",new_issue.fields)
    #new_issue,c_status = jira_obj.issue_create(record.bug_id,i,jira,issue_dict,df)
    #if(c_status=='Y'):
    #j=+1
    status = jira_obj.issue_update(new_issue,update_issue,j,df,record.bug_id)
    print("update status",status)
    j+=1
    #status,description = jira_obj.comments_status(record.bug_id,jira,new_issue,j,df)
    #j+=1
    #print("comment status n description",status,description)
    return j
Example #18
0
def process_columns(record, jira):
    project_name = utilities.readProperty("Projects", "Destination_Project")
    #assignee  = utilities.getQueryResult(queries.assignee_name)
    #project_name = utilities.getQueryResultWith(queries.project_name)
    summary = record.summary
    #component = utilities.getQueryResultWith(queries.component_name,record.component_id)
    jira_obj = jira_record(summary)
    jira_obj.assignee = utilities.get_user(record.assigned_to, jira)

    jira_obj.components = components_result[record.component_id]
    #jira_obj.user_name = utilities.assignee_result[record.assigned_to]
    jira_obj.bug_severity = jira_obj.process_severity(None, default_values[0])
    jira_obj.status = record.bug_status
    jira_obj.priority = jira_obj.process_priority(record.priority,
                                                  default_values[1])
    jira_obj.creation_ts = record.creation_ts.isoformat()
    jira_obj.product_id = record.product_id
    #jira_obj.component_id = record.component_id
    jira_obj.resolution = record.resolution

    jira_obj.phase_of_detection = jira_obj.process_record_validation(
        record.cf_client_phase, default_values[2])
    jira_obj.fix_version = jira_obj.process_record_validation(
        record.cf_fixes_available, default_values[3])
    jira_obj.test_engineer = default_users[2]
    jira_obj.issue_type = jira_obj.process_issue_type(record.cf_type,
                                                      default_values[4])
    jira_obj.test_caseid = record.cf_testcaseid
    jira_obj.build = record.cf_build
    if (record.estimated_time != None):
        jira_obj.estimated_time = utilities.formattime(record.estimated_time)
    else:
        jira_obj.estimated_time = record.record.estimated_time
    if (record.remaining_time != None):
        jira_obj.remaining_estimate = utilities.formattime(
            record.remaining_time)
    else:
        jira_obj.remaining_estimate = record.remaining_time
    if (record.deadline != None):
        jira_obj.due_date = record.deadline.isoformat()

    jira_obj.browser = jira_obj.process_browser(record.cf_browser,
                                                default_values[5])
    jira_obj.os = jira_obj.process_os(record.op_sys, default_values[6])

    issue_dict = {
        "project": {
            "key": project_name
        },
        "summary": summary,
        "description": summary,
        "issuetype": {
            "name": jira_obj.issue_type
        },
        "customfield_10513": jira_obj.test_caseid,
        "components": [{
            "name": jira_obj.components
        }],
        "customfield_10503": {
            "value": jira_obj.phase_of_detection
        },
        "versions": [{
            "name": "Wave 1"
        }],
        "priority": {
            "name": jira_obj.priority
        },
        "customfield_10300": {
            "value": jira_obj.bug_severity
        },
        "customfield_10601": {
            "value": default_users[0]
        }
    }

    update = {"customfield_10601": {"name": jira_obj.test_engineer}}

    #new_issue = jira.create_issue(fields=issue_dict)
    new_issue = jira.issue('TPFWD-2')
    transitions = jira.transitions(new_issue)
    new_issue.update(update)
    #description = process_comments(record.bug_id,jira,new_issue)
    print(new_issue.fields)