Пример #1
0
 def add_data(self):
     sgyt_data = self.db_connection_obj.sess.query(self.db_connection_obj.SEGY_QC_on_disk).filter(
         self.db_connection_obj.SEGY_QC_on_disk.deliverable_id == self.deliverable_id).first()
     self.grid.addWidget(create_center_data(str(self.deliverable.name)), 1, 0)
     if sgyt_data is not None:
         self.data_dict = {self.deliverable.name : sgyt_data}
         self.grid.addWidget(decide_and_create_label(str(sgyt_data.sgyt_status)),1,1)
         self.grid.addWidget(create_center_data(sgyt_data.sgyt_reel_no),1,2)
         self.grid.addWidget(create_center_data(sgyt_data.sgyt_exp_uname),1,3)
         self.grid.addWidget(create_center_data(sgyt_data.sgyt_time_stamp),1,4)
         # now add push button to view log
         pb = QtGui.QPushButton("view SGYT")
         pb.setObjectName(str(self.deliverable.name))
         pb.clicked.connect(self.connect_to_log)
         self.grid.addWidget(pb,1,5)
         self.grid.addWidget(decide_and_create_label(sgyt_data.sgyt_approval_status),1,7) # this will automatically decide and create the necessary label True false or blank
         # pb to approve the log
         pb_approval = QtGui.QPushButton("Approve")
         pb_approval.setObjectName(self.deliverable.name)
         pb_approval.clicked.connect(self.show_approval_popup)
         self.grid.addWidget(pb_approval,1,6)
         #now check and add aprrover name it the approval status is not blank
         if sgyt_data.sgyt_approval_status is not None:
             self.grid.addWidget(create_center_data(sgyt_data.sgyt_approver_name), 1, 8)
             self.grid.addWidget(create_center_data(sgyt_data.sgyt_approval_time), 1, 9)
     else:
         self.grid.addWidget(decide_and_create_label(""), 1, 2)
Пример #2
0
 def add_data(self):
     # search the SEGY on disk QC table to check if the SEGY file for this deliverable
     self.segy_on_disk_qc_obj = self.db_connection_obj.sess.query(self.db_connection_obj.SEGY_QC_on_disk).filter(self.db_connection_obj.SEGY_QC_on_disk.deliverable_id == self.deliverable.id).first()
     if self.segy_on_disk_qc_obj is not None:
         obj_id = self.segy_on_disk_qc_obj.id_seq_segy_qc
         #Now serach for the items in tape write log with the ID corresponding to this id
         self.segy_write_obj_list = self.db_connection_obj.sess.query(
             self.db_connection_obj.SEGY_write
         ).filter(self.db_connection_obj.SEGY_write.id_segy_qc == obj_id).all()
         self.segy_write_obj_dict = {}
         if len(self.segy_write_obj_list) != 0:
             for obj in self.segy_write_obj_list:
                 self.segy_write_obj_dict.update({obj.set_number : obj})
             # now add data
         for i in range(0,self.deliverable.copies):
             self.grid.addWidget(create_center_data(str('Set no: ' + str(i+1))),i+1,0)
             self.grid.addWidget(decide_and_create_label(self.segy_on_disk_qc_obj.segy_on_disk_qc_status),i+1,1)
             if i+1 in self.segy_write_obj_dict.keys():
                 if self.segy_on_disk_qc_obj.segy_on_disk_qc_status:
                     self.grid.addWidget(decide_and_create_label(self.segy_write_obj_dict[i+1].tape_write_status),i+1,2)
                     if self.segy_write_obj_dict[i + 1].tape_write_status:
                         self.grid.addWidget(create_center_data(self.segy_write_obj_dict[i + 1].tape_written_by),i+1,3)
                         self.grid.addWidget(create_center_data(self.segy_write_obj_dict[i + 1].tape_written_on),i+1,4)
                         pb_approve_log = QtGui.QPushButton('View log')
                         pb_approve_log.setObjectName(self.segy_write_obj_dict[i + 1].segy_w_path)
                         pb_approve_log.clicked.connect(self.show_log)
                         self.grid.addWidget(pb_approve_log,i+1,5)
                         if self.segy_write_obj_dict[i + 1].tape_qc_run_status:
                             self.grid.addWidget(decide_and_create_label(self.segy_write_obj_dict[i + 1].tape_qc_status),i+1,6)
                             self.grid.addWidget(create_center_data(self.segy_write_obj_dict[i + 1].tape_checked_by),i+1,7)
                             self.grid.addWidget(create_center_data(self.segy_write_obj_dict[i + 1].tape_checked_on),
                                                 i + 1, 8)
Пример #3
0
 def add_data(self):
     self.data_dir_entry = self.db_connection_obj.sess.query(self.db_connection_obj.Deliverables_data_dir).filter(
         self.db_connection_obj.Deliverables_data_dir.deliverable_id == self.deliverable_id).filter(
         self.db_connection_obj.Deliverables_data_dir.dir_type == 'data').first()
     self.dir_path = self.data_dir_entry.path
     sgyt_data = self.db_connection_obj.sess.query(self.db_connection_obj.SEGY_QC_on_disk).filter(
     self.db_connection_obj.SEGY_QC_on_disk.deliverable_id == self.deliverable_id).first()
     self.data_dict = {self.deliverable.name : sgyt_data}
     self.grid.addWidget(create_center_data(self.deliverable.name), 1, 0)
     self.grid.addWidget(create_center_data(self.deliverable.name), 1, 13)
     self.grid.addWidget(decide_and_create_label(sgyt_data.sgyt_approval_status),1,1)
     if sgyt_data.sgyt_approval_status: # if SGYT approval status is not True do not proceed
             pb_segy_exp = QtGui.QPushButton("Update")
             pb_segy_exp.setObjectName(self.deliverable.name)
             pb_segy_exp.clicked.connect(self.show_export_upate_pop_up)
             self.grid.addWidget(pb_segy_exp,1,2)
             file_name = str(self.deliverable.name + '.sgy')
             file_path = posixpath.join(self.dir_path, file_name)
             status = check_generic_path(self.DUG_connection_obj, file_path)
             if status == 'True': # if the SEGYT file is on disk writing or finished, otherwise STOP
                 self.grid.addWidget(decide_and_create_label(sgyt_data.segy_disk_export_status), 1, 3)
                 if sgyt_data.segy_disk_export_status is not None: # if the export status is set to true or false add exporter name and time stamp labels
                     self.grid.addWidget(create_center_data(sgyt_data.segy_exporter_name),1,4)
                     self.grid.addWidget(create_center_data(sgyt_data.segy_on_disk_time_stamp),1,5)
                     if sgyt_data.segy_disk_export_status: # Add the option to QC the file if the export is set to True
                         self.grid.addWidget(decide_and_create_label(sgyt_data.segy_on_disk_qc_run_status),1,6) # The run status should be update by SEGY on disk QC ops
                         if sgyt_data.segy_on_disk_qc_run_status: # if the run status is True add the button to approve log and link to the log,extractionstatus
                             pb_connect_log = QtGui.QPushButton('View QC log')
                             pb_connect_log.setObjectName(sgyt_data.segy_on_disk_qc_log_path)
                             pb_connect_log.clicked.connect(self.show_QC_log)
                             self.grid.addWidget(pb_connect_log,1,7)
                             self.grid.addWidget(decide_and_create_label(sgyt_data.header_extraction_flag),1,8)
                             if sgyt_data.header_extraction_flag: # if the extraction status is true, add approve button and qc status button
                                 pb_approve_log = QtGui.QPushButton('Approve')
                                 pb_approve_log.setObjectName(sgyt_data.segy_on_disk_qc_log_path)
                                 pb_approve_log.clicked.connect(self.show_approve_qc_log)
                                 self.grid.addWidget(pb_approve_log,1,9)
                                 self.grid.addWidget(decide_and_create_label(sgyt_data.segy_on_disk_qc_status),1,10)
                                 if sgyt_data.segy_on_disk_qc_status is not None: # Now add the time and name for approver
                                     self.grid.addWidget(create_center_data(sgyt_data.segy_on_disk_qc_approver_name),1,11)
                                     self.grid.addWidget(create_center_data(sgyt_data.segy_on_disk_qc_approval_time_stamp), 1, 12)
Пример #4
0
    def check_sgyt_used_aganist_exported_and_add_gui(self):
        db_obj = self.db_connection_obj.sess.query(self.db_connection_obj.SEGY_QC_on_disk).filter(self.db_connection_obj.SEGY_QC_on_disk.segy_on_disk_qc_log_path == self.log_path).first()
        #--------------------------------------------------------------------------------------------
        exported_sgyt_path = db_obj.sgyt_unix_path
        user_sgyt_path = db_obj.sgyt_user_path

        if return_encoded_stripped_sgyt(self.DUG_connection_obj,exported_sgyt_path) == return_encoded_stripped_sgyt(self.DUG_connection_obj,user_sgyt_path):
            sgyt_verification = True
        else:
            sgyt_verification = False
        # Now populate segy file path
        self.segy_name.setText(db_obj.segy_on_disk_file_path)
        # Now add mismatch flag
        self.sgyt_mismatch_flag = decide_and_create_label(sgyt_verification)
        self.grid.addWidget(self.sgyt_mismatch_flag, 4, 1)
        #Now add trace count
        self.no_traces.setText(str(self.extracted_headers_dict['trace_count']))
        self.file_size.setText(str(self.extracted_headers_dict['file_size']))
        #Now add ebcdic_related_headers if sgyt_verification is True
        #creeate EBCDIC key list
        ebcdic_sgyt_mapper_dict = {}
        dict_ebcdic = self.def_dict['ebcdic']
        for key in dict_ebcdic.keys():
            key_to_use = dict_ebcdic[key][0]
            data_to_use = dict_ebcdic[key][2][0]
            ebcdic_sgyt_mapper_dict.update({key_to_use:data_to_use})
        if sgyt_verification:
            self.sgyt_name.setText(db_obj.sgyt_unix_path)
            db_obj_dict = db_obj.__dict__
            # print db_obj_dict
            # print self.line_edit_dict.keys()
            for key in db_obj_dict.keys():
                if key in ebcdic_sgyt_mapper_dict.keys():
                    self.line_edit_dict[key].setText(str(db_obj_dict[ebcdic_sgyt_mapper_dict[key]]))
        else:
            self.diff_file_name = str('sgyt_diff_') + self.segy_name.text()
            cmd = 'diff ' + exported_sgyt_path + " " + user_sgyt_path
            stdin, stdout, stderr =  self.DUG_connection_obj.ws_client.exec_command(cmd)
            self.pop_up_diff = pop_up_text_box_sgyt(stdout.readlines(),'SGT difference')
            self.pop_up_diff.show()
            self.sgyt_name.setText(db_obj.sgyt_unix_path)
            db_obj_dict = db_obj.__dict__
            # print db_obj_dict
            # print self.line_edit_dict.keys()
            for key in db_obj_dict.keys():
                if key in ebcdic_sgyt_mapper_dict.keys():
                    self.line_edit_dict[key].setText(str(db_obj_dict[ebcdic_sgyt_mapper_dict[key]]))

        self.db_obj_update = db_obj
        self.db_obj_dict  = db_obj_dict
        self.ebcdic_sgyt_mapper_dict = ebcdic_sgyt_mapper_dict
        self.sgyt_match_flag = sgyt_verification
Пример #5
0
    def add_db_entries_to_table(self):
        db_entry_reference_dict = {}
        db_entry_plot_dict = {}
        for db_entry in self.db_segd_qc_entry_list:
            db_entry_reference_dict.update({(db_entry.tape_no, db_entry.deliverable_id, db_entry.set_no, db_entry.seq_id):db_entry})
        for tape in self.tape_list:
            for deliverable in self.deliverables_list:
                for i in range(1,int(deliverable.copies)+1):
                    key = (tape.name,deliverable.id,i,tape.sequence_number)
                    if key in db_entry_reference_dict.keys():
                        pass
                    else:
                        db_entry_reference_dict.update({key: None})
        for key in db_entry_reference_dict.keys():
            if db_entry_reference_dict[key] is not None:
                if str(db_entry_reference_dict[key].run_finish) == 'True':
                    db_entry = db_entry_reference_dict[key]
                    rp = self.rv_dict[(db_entry.tape_no,db_entry.seq_id)]
                    self.grid.addWidget(decide_and_create_label(db_entry.run_status),rp,int(self.cv_dict[db_entry.deliverable_id][db_entry.set_no]['Run']))
                    pb = QtGui.QPushButton(str(db_entry.qc_status))
                    obj_name = str(db_entry.tape_no +"-" +str(db_entry.set_no))
                    pb.setObjectName(obj_name)
                    pb.setToolTip(return_SEGD_QC_log_path(self.db_connection_obj,tape_no = obj_name.split("-")[0],set_no=obj_name.split("-")[1]))
                    pb.clicked.connect(self.show_log)
                    if str(db_entry.qc_status) == "True":
                        pb.setStyleSheet('background-color: green')
                    else:
                        pb.setStyleSheet('background-color: red')

                    self.grid.addWidget(pb,rp,int(self.cv_dict[db_entry.deliverable_id][db_entry.set_no]['QC']))
                    self.grid.addWidget(decide_and_create_label('True'), rp,
                                        int(self.cv_dict[db_entry.deliverable_id][db_entry.set_no]['Prod']))
                else:
                    db_entry = db_entry_reference_dict[key]
                    rp = self.rv_dict[(db_entry.tape_no,db_entry.seq_id)]
                    self.grid.addWidget(decide_and_create_label('True'), rp,
                                        int(self.cv_dict[db_entry.deliverable_id][db_entry.set_no]['Prod']))
                    self.grid.addWidget(decide_and_create_label('Running'), rp,
                                        int(self.cv_dict[db_entry.deliverable_id][db_entry.set_no]['Run']))

            else:
                rp = self.rv_dict[key[0], key[3]]
                self.grid.addWidget(decide_and_create_label('Ready'), rp,
                                    int(self.cv_dict[key[1]][key[2]]['Run']))
                self.grid.addWidget(decide_and_create_label('True'), rp,
                                    int(self.cv_dict[key[1]][key[2]]['Prod']))
Пример #6
0
    def __init__(self,parent,type):
        super(approve_form_SEGY_on_disk_qc,self).__init__()
        self.parent = parent
        db_obj_dict = self.parent.db_obj_update.__dict__

        self.def_dict = type_dict[type]

        self.grid = QtGui.QGridLayout()
        #Add label
        label_text = str('Approval form : ' + type_name_dict[type])
        self.grid.addWidget(create_central_labels(label_text),0,0,1,2)
        flag_list_to_use = self.def_dict['flag_list']

        for i in range(0,len(flag_list_to_use)):
            self.grid.addWidget(create_central_labels(flag_name_dict[flag_list_to_use[i]]),i+1,0)
            self.grid.addWidget(decide_and_create_label(db_obj_dict[flag_list_to_use[i]]),i+1,1)
        message = 'Approve or reject: ' + db_obj_dict['segy_on_disk_file_path']

        self.approve_box = pop_up_approval_box(message = message)
        self.approve_box.closed.connect(self.parent.approve_qc_log)

        self.grid.addWidget(self.approve_box,len(flag_list_to_use)+2,0,1,2)

        self.setLayout(self.grid)
 def add_data(self):
     data = self.db_connection_obj.sess.query(
         self.db_connection_obj.SEGY_QC_on_disk).filter(
             self.db_connection_obj.SEGY_QC_on_disk.deliverable_id ==
             self.deliverable.id).order_by(
                 self.db_connection_obj.SEGY_QC_on_disk.id_seq_segy_qc).all(
                 )
     #now create a dictinoary for status
     data_dict = {}
     for obj in data:
         key = obj.line_name
         data = obj
         data_dict.update({key: data})
     self.data_dict = data_dict
     #Now search for all available lines that have been shot in orca line
     lines_shot = self.db_connection_obj.sess.query(
         self.db_connection_obj.Line).order_by(
             self.db_connection_obj.Line.sequence_number).all()
     line_name_list = []
     for aline in lines_shot:
         if int(aline.sequence_number) < 9000:
             line_name_list.append(
                 (aline.sequence_number, aline.real_line_name))
         else:
             pass
     # now add the objects in the line_name_list
     for i in range(1, len(line_name_list) + 1):
         self.grid.addWidget(
             create_center_data(str(line_name_list[i - 1][0])), i, 0)
         self.grid.addWidget(create_center_data(line_name_list[i - 1][1]),
                             i, 1)
         #now check if some data exists for this in the data_dict
         if line_name_list[i - 1][1] in data_dict.keys():
             #if yes
             sgyt_data = data_dict[line_name_list[i - 1][1]]
             self.grid.addWidget(
                 decide_and_create_label(str(sgyt_data.sgyt_status)), i, 2)
             self.grid.addWidget(create_center_data(sgyt_data.sgyt_reel_no),
                                 i, 3)
             self.grid.addWidget(
                 create_center_data(sgyt_data.sgyt_exp_uname), i, 4)
             self.grid.addWidget(
                 create_center_data(sgyt_data.sgyt_time_stamp), i, 5)
             # now add push button to view log
             pb = QtGui.QPushButton("view SGYT")
             pb.setObjectName(line_name_list[i - 1][1])
             pb.setToolTip(
                 self.data_dict[line_name_list[i - 1][1]].sgyt_unix_path)
             pb.clicked.connect(self.connect_to_log)
             self.grid.addWidget(pb, i, 6)
             self.grid.addWidget(
                 decide_and_create_label(str(
                     sgyt_data.sgyt_approval_status)), i, 8
             )  # this will automatically decide and create the necessary label True false or blank
             # pb to approve the log
             pb_approval = QtGui.QPushButton("Approve")
             pb_approval.setObjectName(line_name_list[i - 1][1])
             pb_approval.clicked.connect(self.show_approval_popup)
             self.grid.addWidget(pb_approval, i, 7)
             #now check and add aprrover name it the approval status is not blank
             if sgyt_data.sgyt_approval_status is not None:
                 self.grid.addWidget(
                     create_center_data(sgyt_data.sgyt_approver_name), i, 9)
                 self.grid.addWidget(
                     create_center_data(sgyt_data.sgyt_approval_time), i,
                     10)
         else:
             self.grid.addWidget(decide_and_create_label(""), i, 2)
    def add_data(self):
        #Creating the data for SEGY QC for all entries for a particular deliverable
        data_segy_qc = self.db_connection_obj.sess.query(
            self.db_connection_obj.SEGY_QC_on_disk).filter(
                self.db_connection_obj.SEGY_QC_on_disk.deliverable_id ==
                self.deliverable.id).order_by(
                    self.db_connection_obj.SEGY_QC_on_disk.id_seq_segy_qc).all(
                    )
        #valid SEGY QC id list for the case
        valid_segy_qc_list = []
        for item in data_segy_qc:
            valid_segy_qc_list.append(item.id_seq_segy_qc)
        # now create a dictinoary for status
        self.segy_ondisk_data_dict = {}  # {linename : DAO for segy QC}
        for obj in data_segy_qc:
            if obj.segy_on_disk_qc_run_status:  # for all the objects in SEGY on disk QC we ony want the ones where SEGY on disk QC was run to distinguish between ready and True of False
                key = obj.line_name
                data = obj
                self.segy_ondisk_data_dict.update({key: data})
        # Now search for all available lines that have been shot in orca line
        lines_shot = self.db_connection_obj.sess.query(
            self.db_connection_obj.Line).order_by(
                self.db_connection_obj.Line.sequence_number).all()
        line_name_list = []
        for aline in lines_shot:
            if int(aline.sequence_number) < 9000:
                line_name_list.append(
                    (aline.sequence_number, aline.real_line_name))
            else:
                pass
        # creating the data for SEGY write
        data_segy_write = self.db_connection_obj.sess.query(
            self.db_connection_obj.SEGY_write).filter(
                self.db_connection_obj.SEGY_write.set_number ==
                self.set_no).all()
        self.segy_write_obj_dict_set_wise = {
        }  # { SEGYQC_id : DAO for SEGY write}
        for obj in data_segy_write:
            if obj.id_segy_qc in valid_segy_qc_list:
                self.segy_write_obj_dict_set_wise.update({obj.id_segy_qc: obj})

        # now add the objects
        for i in range(1,
                       len(line_name_list) +
                       1):  # This needs to be added one more time
            self.grid.addWidget(
                create_center_data(str(line_name_list[i - 1][0])), i, 1)

            self.grid.addWidget(create_center_data(line_name_list[i - 1][1]),
                                i, 2)

            if line_name_list[i - 1][1] in self.segy_ondisk_data_dict.keys():
                self.grid.addWidget(
                    decide_and_create_label(self.segy_ondisk_data_dict[
                        line_name_list[i - 1][1]].segy_on_disk_qc_status), i,
                    3)
                segy_qc_id = self.segy_ondisk_data_dict[line_name_list[i - 1]
                                                        [1]].id_seq_segy_qc
                if segy_qc_id in self.segy_write_obj_dict_set_wise.keys():
                    self.grid.addWidget(
                        create_central_labels(
                            self.segy_write_obj_dict_set_wise[segy_qc_id].
                            tape_label), i, 0)
                    self.grid.addWidget(
                        decide_and_create_label(
                            self.segy_write_obj_dict_set_wise[segy_qc_id].
                            tape_write_status), i, 4)
                    self.grid.addWidget(
                        create_center_data(
                            self.segy_write_obj_dict_set_wise[segy_qc_id].
                            tape_written_by), i, 5)
                    self.grid.addWidget(
                        create_center_data(
                            self.segy_write_obj_dict_set_wise[segy_qc_id].
                            tape_written_on), i, 6)
                    pb_view_log = QtGui.QPushButton('View log')
                    pb_view_log.setObjectName(str(segy_qc_id))
                    pb_view_log.clicked.connect(self.show_log)
                    self.grid.addWidget(pb_view_log, i, 7)
                    if self.segy_write_obj_dict_set_wise[
                            segy_qc_id].tape_qc_run_status:  # If the tape qc was run
                        self.grid.addWidget(
                            decide_and_create_label(
                                self.segy_write_obj_dict_set_wise[segy_qc_id].
                                tape_qc_status), i, 8)
                        self.grid.addWidget(
                            create_center_data(
                                self.segy_write_obj_dict_set_wise[segy_qc_id].
                                tape_checked_by), i, 9)
                        self.grid.addWidget(
                            create_center_data(
                                self.segy_write_obj_dict_set_wise[segy_qc_id].
                                tape_checked_on), i, 10)
                else:
                    if self.segy_ondisk_data_dict[line_name_list[i - 1]
                                                  [1]].segy_on_disk_qc_status:
                        self.grid.addWidget(decide_and_create_label(""), i, 3)
    def add_data(self):
        set_start_column = 3
        data_segy_qc = self.db_connection_obj.sess.query(
            self.db_connection_obj.SEGY_QC_on_disk).filter(
                self.db_connection_obj.SEGY_QC_on_disk.deliverable_id ==
                self.deliverable.id).order_by(
                    self.db_connection_obj.SEGY_QC_on_disk.id_seq_segy_qc).all(
                    )
        # valid SEGY QC id list for the case
        valid_segy_qc_list = []
        for item in data_segy_qc:
            valid_segy_qc_list.append(item.id_seq_segy_qc)
        # now create a dictinoary for status
        self.segy_ondisk_data_dict = {}
        for obj in data_segy_qc:
            if obj.segy_on_disk_qc_run_status:  # for all the objects in SEGY on disk QC we ony want the ones where SEGY on disk QC was run to distinguish between ready and True of False
                key = obj.line_name
                data = obj
                self.segy_ondisk_data_dict.update({key: data})
        # Now search for all available lines that have been shot in orca line
        lines_shot = self.db_connection_obj.sess.query(
            self.db_connection_obj.Line).order_by(
                self.db_connection_obj.Line.sequence_number).all()
        line_name_list = []
        for aline in lines_shot:
            if int(aline.sequence_number) < 9000:
                line_name_list.append(
                    (aline.sequence_number, aline.real_line_name))
            else:
                pass
        # creating the data for SEGY write
        data_segy_write = self.db_connection_obj.sess.query(
            self.db_connection_obj.SEGY_write).all()
        self.segy_write_obj_dict = {}
        for obj in data_segy_write:
            if obj.id_segy_qc in valid_segy_qc_list:
                self.segy_write_obj_dict.update({
                    (obj.id_segy_qc, int(obj.set_number)):
                    obj
                })

        #print self.segy_write_obj_dict

        # now add the objects
        for i in range(1,
                       len(line_name_list) +
                       1):  # This needs to be added one more time
            self.grid.addWidget(
                create_center_data(str(line_name_list[i - 1][0])), i + 1, 0)
            self.grid.addWidget(create_center_data(line_name_list[i - 1][1]),
                                i + 1, 1)
            if line_name_list[i - 1][1] in self.segy_ondisk_data_dict.keys():
                self.grid.addWidget(
                    decide_and_create_label(self.segy_ondisk_data_dict[
                        line_name_list[i - 1][1]].segy_on_disk_qc_status),
                    i + 1, 2)
                segy_qc_id = self.segy_ondisk_data_dict[line_name_list[i - 1]
                                                        [1]].id_seq_segy_qc
                if self.segy_ondisk_data_dict[line_name_list[i - 1]
                                              [1]].segy_on_disk_qc_status:
                    for j in range(0, self.deliverable.copies):
                        if (segy_qc_id,
                                j + 1) in self.segy_write_obj_dict.keys():
                            self.grid.addWidget(
                                decide_and_create_label(
                                    self.segy_write_obj_dict[(
                                        segy_qc_id, j + 1)].tape_write_status),
                                i + 1, (int(self.segy_write_obj_dict[
                                    (segy_qc_id, j + 1)].set_number) - 1) * 2 +
                                set_start_column)
                            if self.segy_write_obj_dict[(
                                    segy_qc_id, j + 1
                            )].tape_qc_run_status:  # If the tape qc was run
                                self.grid.addWidget(
                                    decide_and_create_label(
                                        self.segy_write_obj_dict[(
                                            segy_qc_id,
                                            j + 1)].tape_qc_status), i + 1,
                                    (int(self.segy_write_obj_dict[
                                        (segy_qc_id, j + 1)].set_number) - 1) *
                                    2 + set_start_column + 1)
                        else:
                            self.grid.addWidget(decide_and_create_label(""),
                                                i + 1,
                                                j * 2 + set_start_column)
    def add_data(self):
        self.data_dir_entry = self.db_connection_obj.sess.query(
            self.db_connection_obj.Deliverables_data_dir).filter(
                self.db_connection_obj.Deliverables_data_dir.deliverable_id ==
                self.deliverable_id).filter(
                    self.db_connection_obj.Deliverables_data_dir.dir_type ==
                    'data').first()
        self.dir_path = self.data_dir_entry.path
        # data = self.db_connection_obj.sess.query(self.db_connection_obj.SEGY_QC_on_disk).filter(self.db_connection_obj.SEGY_QC_on_disk.deliverable_id == self.deliverable_id).order_by(
        #     self.db_connection_obj.SEGY_QC_on_disk.id_seq_segy_qc).all()
        data = get_data_for_SEGY_qc(self.db_connection_obj,
                                    self.deliverable_id)
        # now create a dictinoary for status
        data_dict = {}
        for obj in data:
            key = obj.line_name
            data = obj
            data_dict.update({key: data})
        self.data_dict = data_dict
        # Now search for all available lines that have been shot in orca line
        lines_shot = self.db_connection_obj.sess.query(
            self.db_connection_obj.Line).order_by(
                self.db_connection_obj.Line.sequence_number).all()
        line_name_list = []
        for aline in lines_shot:
            if int(aline.sequence_number) < 9000:
                line_name_list.append(
                    (aline.sequence_number, aline.real_line_name))
            else:
                pass
        #now fetch the directory content list
        cmd = str("ls " + self.dir_path)
        available_file_list = fetch_directory_content_list(
            self.DUG_connection_obj, cmd)
        available_file_dict = {}
        for a_line in line_name_list:
            a_line_name_segy = str(a_line[1] + '.sgy')
            if a_line_name_segy in available_file_list:
                available_file_dict.update({a_line[1]: True})
            else:
                available_file_dict.update({a_line[1]: False})

        # now add the objects in the line_name_list
        for i in range(1, len(line_name_list) + 1):
            # the 1st two and the last two columens
            self.grid.addWidget(
                create_center_data(str(line_name_list[i - 1][0])), i, 0)
            self.grid.addWidget(create_center_data(line_name_list[i - 1][1]),
                                i, 1)
            self.grid.addWidget(
                create_center_data(str(line_name_list[i - 1][0])), i, 15)
            self.grid.addWidget(create_center_data(line_name_list[i - 1][1]),
                                i, 14)
            # now check if some data exists for this in the data_dict
            if line_name_list[i - 1][1] in data_dict.keys():
                sgyt_data = data_dict[line_name_list[i - 1][1]]
                self.grid.addWidget(
                    decide_and_create_label(sgyt_data.sgyt_approval_status), i,
                    2)  # add SGYT QC status
                if sgyt_data.sgyt_approval_status:  # if SGYT approval status is not True do not proceed
                    pb_segy_exp = QtGui.QPushButton("Update")
                    pb_segy_exp.setObjectName(sgyt_data.line_name)
                    pb_segy_exp.setToolTip(
                        posixpath.join(self.dir_path,
                                       str(sgyt_data.line_name + '.sgy')))
                    pb_segy_exp.clicked.connect(self.show_export_upate_pop_up)
                    self.grid.addWidget(pb_segy_exp, i, 3)
                    file_name = str(sgyt_data.line_name + '.sgy')
                    file_path = posixpath.join(self.dir_path, file_name)
                    status = available_file_dict[sgyt_data.line_name]
                    if status:  # if the SEGYT file is on disk writing or finished, otherwise STOP
                        self.grid.addWidget(
                            decide_and_create_label(
                                sgyt_data.segy_disk_export_status), i, 4)
                        if sgyt_data.segy_disk_export_status is not None:  # if the export status is set to true or false add exporter name and time stamp labels
                            self.grid.addWidget(
                                create_center_data(
                                    sgyt_data.segy_exporter_name), i, 5)
                            self.grid.addWidget(
                                create_center_data(
                                    sgyt_data.segy_on_disk_time_stamp), i, 6)
                            if sgyt_data.segy_disk_export_status:  # Add the option to QC the file if the export is set to True
                                self.grid.addWidget(
                                    decide_and_create_label(
                                        sgyt_data.segy_on_disk_qc_run_status),
                                    i, 7
                                )  # The run status should be update by SEGY on disk QC ops
                                if sgyt_data.segy_on_disk_qc_run_status:  # if the run status is True add the button to approve log and link to the log,extractionstatus
                                    pb_connect_log = QtGui.QPushButton(
                                        'View QC log')
                                    pb_connect_log.setObjectName(
                                        sgyt_data.segy_on_disk_qc_log_path)
                                    pb_connect_log.setToolTip(
                                        sgyt_data.segy_on_disk_qc_log_path)
                                    pb_connect_log.clicked.connect(
                                        self.show_QC_log)
                                    self.grid.addWidget(pb_connect_log, i, 8)
                                    self.grid.addWidget(
                                        decide_and_create_label(
                                            sgyt_data.header_extraction_flag),
                                        i, 9)
                                    if sgyt_data.header_extraction_flag:  # if the extraction status is true, add approve button and qc status button
                                        pb_approve_log = QtGui.QPushButton(
                                            'Approve')
                                        pb_approve_log.setObjectName(
                                            sgyt_data.segy_on_disk_qc_log_path)
                                        pb_approve_log.clicked.connect(
                                            self.show_approve_qc_log)
                                        self.grid.addWidget(
                                            pb_approve_log, i, 10)
                                        self.grid.addWidget(
                                            decide_and_create_label(
                                                sgyt_data.
                                                segy_on_disk_qc_status), i, 11)
                                        if sgyt_data.segy_on_disk_qc_status is not None:  # Now add the time and name for approver
                                            self.grid.addWidget(
                                                create_center_data(
                                                    sgyt_data.
                                                    segy_on_disk_qc_approver_name
                                                ), i, 12)
                                            self.grid.addWidget(
                                                create_center_data(
                                                    sgyt_data.
                                                    segy_on_disk_qc_approval_time_stamp
                                                ), i, 13)