Exemplo n.º 1
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)
Exemplo n.º 2
0
    def __init__(self, parent):

        super(project_info, self).__init__(parent=parent)
        self.parent = parent
        self.db_connection_obj = self.parent.db_connection_obj  # use this line to pass the connection object between the parent and the child
        self.project_info = fetch_project_info(self.db_connection_obj)
        grid = QtGui.QGridLayout()
        grid.addWidget(create_central_labels('General Project information'), 0,
                       0, 1, 2)
        if self.project_info == None or len(self.project_info) == 0:
            grid.addWidget(
                create_center_data(
                    "Project information from ORCA is not available !!!"), 1,
                0, 1, 2)
        else:
            info_dict = self.project_info[0].__dict__
            j = 0

            for key in info_dict:
                if key != '_sa_instance_state':
                    j = j + 1
                    #print key , info_dict[key]
                    grid.addWidget(create_center_data(key), j, 0)
                    grid.addWidget(
                        create_left_blank(str(info_dict[key]), 'blue'), j, 1)

        self.setLayout(grid)
Exemplo n.º 3
0
 def add_tape_sequence_labels(self):
     rv_dict = {}  # row values for SEG QC entries
     for i in range(0,len(self.tape_list)):
         seq_name = fetch_seq_name_from_id(self.db_connection_obj,self.tape_list[i].sequence_number)
         self.grid.addWidget(create_center_data(self.tape_list[i].name),i+4,1,1,1)
         self.grid.addWidget(create_center_data(seq_name), i + 4, 0, 1, 1)
         rv_dict.update({(self.tape_list[i].name, self.tape_list[i].sequence_number):i+4})
     self.rv_dict = rv_dict
    def __init__(self, parent, id):
        # define the top window

        super(edit_shipment, self).__init__(parent=parent)
        self.parent = parent
        self.db_connection_obj = self.parent.db_connection_obj
        self.DUG_connection_obj = self.parent.DUG_connection_obj

        grid = QtGui.QGridLayout()

        self.new_shipment = self.db_connection_obj.sess.query(
            self.db_connection_obj.Shipments).filter(
                self.db_connection_obj.Shipments.id == id).first()

        self.result = self.new_shipment.__dict__

        keys_list = [
            'Id', 'Shipment Number', 'Air way bill number', "Number of boxes"
        ]
        keys_dict = {}
        keys_dict['Id'] = create_center_data('Automatic')
        keys_dict['Shipment Number'] = QtGui.QLineEdit()
        keys_dict['Air way bill number'] = QtGui.QLineEdit()
        keys_dict["Number of boxes"] = QtGui.QLineEdit()

        self.shipment_def = keys_dict

        for i in range(0, len(keys_list)):
            grid.addWidget(create_center_data(keys_list[i]), i + 1, 0)
            grid.addWidget(keys_dict[keys_list[i]], i + 1, 1, 1, 2)

        for i in range(len(keys_list), 22):
            grid.addWidget(create_center_blank(""), i + 1, 1)

        j = len(keys_list)

        self.pb_save = QtGui.QPushButton()
        self.pb_save.setText('Update')
        self.pb_save.setStatusTip('Save Shipment to the database')
        self.pb_save.clicked.connect(self.update_shipment)

        grid.addWidget(self.pb_save, j + 1, 0)

        self.pb_exit = QtGui.QPushButton()
        self.pb_exit.setText('Back')
        self.pb_exit.setStatusTip('Back to main deliverables Menu')
        self.pb_exit.clicked.connect(self.parent.set_shipments_summary)

        grid.addWidget(self.pb_exit, j + 2, 0)

        self.object_to_gui()

        self.setLayout(grid)

        self.show()
Exemplo n.º 5
0
    def __init__(self, parent, id):
        # define the top window

        super(edit_usb_window, self).__init__(parent=parent)
        self.parent = parent
        self.db_connection_obj = self.parent.db_connection_obj
        self.DUG_connection_obj = self.parent.DUG_connection_obj

        grid = QtGui.QGridLayout()

        self.new_usb = self.db_connection_obj.sess.query(
            self.db_connection_obj.USB_list).filter(
                self.db_connection_obj.USB_list.usb_id == id).first()

        self.result = self.new_usb.__dict__

        keys_list = ['Id', 'Label', 'Capacity in TB', "Serial no"]

        keys_dict = {}
        keys_dict['Id'] = create_center_data('Automatic')
        keys_dict['Label'] = QtGui.QLineEdit()
        keys_dict['Capacity in TB'] = QtGui.QLineEdit()
        keys_dict['Serial no'] = QtGui.QLineEdit()

        self.usb_def = keys_dict

        for i in range(0, len(keys_list)):
            grid.addWidget(create_center_data(keys_list[i]), i + 1, 0)
            grid.addWidget(keys_dict[keys_list[i]], i + 1, 1, 1, 2)

        for i in range(len(keys_list), 15):
            grid.addWidget(create_center_blank(""), i + 1, 1)

        j = len(keys_list)

        self.pb_save = QtGui.QPushButton()
        self.pb_save.setText('Update')
        self.pb_save.setStatusTip('Save USB to the database')
        self.pb_save.clicked.connect(self.update_usb)

        grid.addWidget(self.pb_save, j + 1, 0)

        self.pb_exit = QtGui.QPushButton()
        self.pb_exit.setText('Back')
        self.pb_exit.setStatusTip('Back to main USB Menu')
        self.pb_exit.clicked.connect(self.parent.set_usb_summary)

        grid.addWidget(self.pb_exit, j + 2, 0)

        self.object_to_gui()

        self.setLayout(grid)

        self.show()
    def __init__(self, parent):
        # define the top window

        super(add_new_shipment, self).__init__(parent=parent)

        self.parent = parent
        self.db_connection_obj = self.parent.db_connection_obj
        self.DUG_connection_obj = self.parent.DUG_connection_obj

        grid = QtGui.QGridLayout()

        grid.addWidget(create_central_labels("Create New shipment"), 0, 0, 1,
                       3)

        keys_list = [
            'Id', 'Shipment Number', 'Air way bill number', "Number of boxes"
        ]

        keys_dict = {}
        keys_dict['Id'] = create_center_data('Automatic')
        keys_dict['Shipment Number'] = QtGui.QLineEdit()
        keys_dict['Air way bill number'] = QtGui.QLineEdit()
        keys_dict["Number of boxes"] = QtGui.QLineEdit()

        self.shipment_def = keys_dict

        for i in range(0, len(keys_list)):
            grid.addWidget(create_center_data(keys_list[i]), i + 1, 0)
            grid.addWidget(keys_dict[keys_list[i]], i + 1, 1, 1, 2)

        for i in range(len(keys_list), 15):
            grid.addWidget(create_center_blank(""), i + 1, 1)

        self.pb_save = QtGui.QPushButton()
        self.pb_save.setText('Save')
        self.pb_save.setStatusTip('Save Shipment to the database')
        self.pb_save.clicked.connect(self.save_shipment)

        grid.addWidget(self.pb_save, 17, 0)

        self.pb_exit = QtGui.QPushButton()
        self.pb_exit.setText('Back')
        self.pb_exit.setStatusTip('Back to main Shipment Menu')
        self.pb_exit.clicked.connect(self.parent.set_shipment_tools)

        grid.addWidget(self.pb_exit, 17, 1)

        self.setLayout(grid)
Exemplo n.º 7
0
    def __init__(self, parent):
        # define the top window

        super(add_usb_label, self).__init__()

        self.parent = parent
        self.db_connection_obj = self.parent.db_connection_obj
        self.DUG_connection_obj = self.parent.DUG_connection_obj

        grid = QtGui.QGridLayout()

        grid.addWidget(create_central_labels("Create New USB label"), 0, 0, 1,
                       3)

        keys_list = ['Id', 'Label', 'Capacity in TB', "Serial no"]

        keys_dict = {}
        keys_dict['Id'] = create_center_data('Automatic')
        keys_dict['Label'] = QtGui.QLineEdit()
        keys_dict['Capacity in TB'] = QtGui.QLineEdit()
        keys_dict['Serial no'] = QtGui.QLineEdit()

        self.usb_def = keys_dict

        for i in range(0, len(keys_list)):
            grid.addWidget(create_center_data(keys_list[i]), i + 1, 0)
            grid.addWidget(keys_dict[keys_list[i]], i + 1, 1, 1, 2)

        for i in range(len(keys_list), 15):
            grid.addWidget(create_center_blank(""), i + 1, 1)

        self.pb_save = QtGui.QPushButton()
        self.pb_save.setText('Save')
        self.pb_save.setStatusTip('Save USB label to database')
        self.pb_save.clicked.connect(self.save_usb_label)

        grid.addWidget(self.pb_save, 17, 0)

        self.pb_exit = QtGui.QPushButton()
        self.pb_exit.setText('Back')
        self.pb_exit.setStatusTip('Back to main Shipment Menu')
        self.pb_exit.clicked.connect(self.parent.set_usb_functions)

        grid.addWidget(self.pb_exit, 17, 1)

        self.setLayout(grid)
Exemplo n.º 8
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)
 def create_widgets_dict(self):
     self.dst_widget_dict = {}
     self.dst_label_dict = {}
     self.dst_position_dict = {}
     for dst in self.tape_service.available_dst:
         text_edit_obj = QtGui.QTextEdit()
         label = create_center_data(dst)
         position = dst[len(dst)-1]
         widject_dict_obj = {dst:text_edit_obj}
         label_dict_obj = {dst:label}
         position_dict_obj = {dst:position}
         self.dst_widget_dict.update(widject_dict_obj)
         self.dst_label_dict.update(label_dict_obj)
         self.dst_position_dict.update(position_dict_obj)
Exemplo n.º 10
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)
    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)
Exemplo n.º 12
0
    def __init__(self, parent):
        # define the top window

        super(Deliverables_summary_window, self).__init__(parent=parent)
        self.parent = parent
        self.tool_tip_dict = tool_tips_mapper_dict['deliverables']
        self.setToolTip(self.tool_tip_dict['general'])
        self.db_connection_obj = self.parent.db_connection_obj  # use this line to pass the connection object between the parent and the child
        grid = QtGui.QGridLayout()
        #header
        title = create_central_labels('Deliverables sumary')
        title.setMaximumHeight(50)
        grid.addWidget(title, 0, 0, 1, 6)

        #---------------------------------------------
        #  **creating the label for the widget table
        #---------------------------------------------
        labels_text = ["Id", "Name", "Class", "Type", "Media", "Copies"]
        labels_list = []
        for label in labels_text:
            labels_list.append(create_central_labels(label))
        for i in range(0, len(labels_list)):
            grid.addWidget(labels_list[i], 1, i)
        #----------------------------------------------------------------------------------
        #  **** Now searcing for existing deliverables in the database and displaying them
        #----------------------------------------------------------------------------------
        self.existing_deliverables_list_dict = fetch_deliverables_list(
            self.db_connection_obj)
        sobj = self.existing_deliverables_list_dict
        for j in range(0, len(sobj)):
            grid.addWidget(create_center_data(str(sobj[j]['id'])), j + 2, 0)
            grid.addWidget(create_center_data(str(sobj[j]['name'])), j + 2, 1)
            grid.addWidget(create_center_data(str(sobj[j]['class_d'])), j + 2,
                           2)
            grid.addWidget(create_center_data(str(sobj[j]['type'])), j + 2, 3)
            grid.addWidget(create_center_data(str(sobj[j]['media'])), j + 2, 4)
            grid.addWidget(create_center_data(str(sobj[j]['copies'])), j + 2,
                           5)

        #Make it look organized------------------------------------------------
        for j in range(len(sobj), 22):
            for i in range(0, 6):
                grid.addWidget(create_center_blank(""), j + 1, i)
        #----------------------------------------------------------
        # Adding the button to add deliverable, edit existing one or delete
        #----------------------------------------------------------
        j = 22
        self.pb_add = QtGui.QPushButton()
        self.pb_add.setText("+")
        self.pb_add.clicked.connect(self.parent.set_new_deliverable)
        grid.addWidget(self.pb_add, j, 0)
        self.pb_add.setToolTip(self.tool_tip_dict['add'])

        self.pb_edit = QtGui.QPushButton()
        self.pb_edit.setText('Edit')
        self.pb_edit.clicked.connect(self.edit_single_deliverable)
        grid.addWidget(self.pb_edit, j, 2)
        self.pb_edit.setToolTip(self.tool_tip_dict['edit'])

        self.pb_view = QtGui.QPushButton()
        self.pb_view.setText('View')
        self.pb_view.clicked.connect(self.view_single_deliverable_detail)
        grid.addWidget(self.pb_view, j, 1)
        self.pb_view.setToolTip(self.tool_tip_dict['view'])

        self.pb_delete = QtGui.QPushButton()
        self.pb_delete.setText('Delete')
        self.pb_delete.clicked.connect(self.delete_deliverable)
        grid.addWidget(self.pb_delete, j, 3)
        self.pb_delete.setToolTip(self.tool_tip_dict['delete'])

        self.pb_home = QtGui.QPushButton()
        self.pb_home.setText('Exit')
        self.pb_home.clicked.connect(self.parent.show_project_info)
        grid.addWidget(self.pb_home, j, 5)
        self.pb_home.setToolTip(self.tool_tip_dict['exit'])

        self.setLayout(grid)
    def __init__(self, parent):
        # define the top window

        super(add_new_deliverable, self).__init__(parent=parent)
        self.parent = parent
        self.db_connection_obj = self.parent.db_connection_obj
        self.DUG_connection_obj = self.parent.DUG_connection_obj  # use this line to pass the connection object between the parent and the child
        self.tool_tip_dict = tool_tips_mapper_dict['single_deliverable']
        self.setToolTip(self.tool_tip_dict['general'])

        self.dir_service = deliverable_dir_service(self)

        grid = QtGui.QGridLayout()
        #-------------------------------------------
        #add title
        #-------------------------------------------
        grid.addWidget(create_central_labels('New deliverable description'), 0,
                       0, 1, 2)
        #--------------------------------------------
        # deliverable attributes
        #--------------------------------------------
        keys_list = [
            'id',
            'name',
            'class_d',
            'type',
            'media',
            'copies',
            'prod_version',
            'reel_prefix',
            'sgyt',
            'bin_def',
            'trc_def',
        ]
        keys_dict = {}
        keys_dict['id'] = create_center_data('Automatic')
        keys_dict['name'] = QtGui.QLineEdit()
        class_choice = QtGui.QComboBox()
        class_choice.addItems(deliverable_classes)
        keys_dict['class_d'] = class_choice
        type_choice = QtGui.QComboBox()
        type_choice.addItems(deliverable_type_list)
        keys_dict['type'] = type_choice
        media_choice = QtGui.QComboBox()
        media_choice.addItems(valid_media_list)
        keys_dict['media'] = media_choice
        keys_dict['copies'] = QtGui.QLineEdit()
        keys_dict['prod_version'] = QtGui.QLineEdit()
        keys_dict['sgyt'] = QtGui.QLineEdit()
        keys_dict['bin_def'] = QtGui.QLineEdit()
        keys_dict['trc_def'] = QtGui.QLineEdit()
        keys_dict['reel_prefix'] = QtGui.QLineEdit()

        for a_key in keys_list:
            keys_dict[a_key].setToolTip(self.tool_tip_dict[a_key])

        self.deliverable_def = keys_dict

        pb_sgyt = QtGui.QPushButton()
        pb_sgyt.setText('Select SGYT file')
        pb_sgyt.clicked.connect(self.browse_sgyt)

        pb_bin_def = QtGui.QPushButton()
        pb_bin_def.setText('Select bin.def file')
        pb_bin_def.clicked.connect(self.browse_bin_def)

        pb_trc_def = QtGui.QPushButton()
        pb_trc_def.setText('Select trc.def file')
        pb_trc_def.clicked.connect(self.browse_trc_def)

        for i in range(0, len(keys_list)):
            grid.addWidget(create_central_labels(str(keys_list[i])), i + 1, 0)
            grid.addWidget(keys_dict[keys_list[i]], i + 1, 1)

        grid.addWidget(pb_sgyt, 9, 2)
        grid.addWidget(pb_bin_def, 10, 2)
        grid.addWidget(pb_trc_def, 11, 2)

        j = len(keys_list)

        self.pb_save = QtGui.QPushButton()
        self.pb_save.setText('Save')
        self.pb_save.setStatusTip('Save deliverable to the database')
        self.pb_save.clicked.connect(self.save_deliverable)

        grid.addWidget(self.pb_save, j + 1, 0)

        self.pb_exit = QtGui.QPushButton()
        self.pb_exit.setText('Back')
        self.pb_exit.setStatusTip('Back to main deliverables Menu')
        self.pb_exit.clicked.connect(self.parent.set_deliverables_window)

        grid.addWidget(self.pb_exit, j + 2, 0)

        self.setLayout(grid)
    def __init__(self, parent):
        # define the top window

        super(usb_summary_window, self).__init__()
        self.parent = parent
        self.db_connection_obj = self.parent.db_connection_obj
        self.DUG_connection_obj = self.parent.DUG_connection_obj

        grid =  QtGui.QGridLayout()

        grid.addWidget(create_central_labels("USB Summary"),0,0,1,4)

        labels_text = ["Id", "USB # ",  "Capacity" , "Serial #"]
        labels_list = []
        for label in labels_text:
            labels_list.append(create_central_labels(label))
        for i in range(0, len(labels_list)):
            grid.addWidget(labels_list[i], 1, i)

        # ----------------------------------------------------------------------------------
        #  **** Now searcing for existing shipments in the database and displaying them
        # ----------------------------------------------------------------------------------
        self.existing_usb_list_dict = fetch_usb_list_dict(self.db_connection_obj)

        sobj = self.existing_usb_list_dict

        for j in range(0, len(sobj)):
            grid.addWidget(create_center_data(str(sobj[j]['usb_id'])), j + 2, 0)
            grid.addWidget(create_center_data(str(sobj[j]['label'])), j + 2, 1)
            grid.addWidget(create_center_data(str(sobj[j]['capacity_tb'])), j + 2, 2)
            grid.addWidget(create_center_data(str(sobj[j]['serial_no'])), j + 2, 3)


        # Make it look organized------------------------------------------------
        for j in range(len(sobj), 22):
            for i in range(0, 4):
                grid.addWidget(create_center_blank(""), j + 1, i)
        # ----------------------------------------------------------
        # Adding the button to add deliverable, edit existing one or delete
        # ----------------------------------------------------------
        j = 22

        self.pb_add = QtGui.QPushButton()
        self.pb_add.setText("+")
        self.pb_add.setStatusTip('Add more USB')
        self.pb_add.clicked.connect(self.parent.set_add_usb_label)
        grid.addWidget(self.pb_add, j, 0)

        self.pb_edit = QtGui.QPushButton()
        self.pb_edit.setText('Edit')
        self.pb_edit.setStatusTip('Edit and existing USB')
        self.pb_edit.clicked.connect(self.edit_single_usb)
        grid.addWidget(self.pb_edit, j, 1)

        self.pb_delete = QtGui.QPushButton()
        self.pb_delete.setText('Delete')
        self.pb_delete.setStatusTip('Delete an existing USB')
        self.pb_delete.clicked.connect(self.delete_usb)
        grid.addWidget(self.pb_delete, j, 2)

        self.pb_home = QtGui.QPushButton()
        self.pb_home.setText('Exit')
        self.pb_home.setStatusTip('Exit and return to Home screen ')
        self.pb_home.clicked.connect(self.parent.show_project_info)
        grid.addWidget(self.pb_home, j, 3)

        self.setLayout(grid)
    def __init__(self, parent):
        # define the top window

        super(shipment_summary, self).__init__()
        self.parent = parent
        self.db_connection_obj = self.parent.db_connection_obj
        self.DUG_connection_obj = self.parent.DUG_connection_obj

        grid = QtGui.QGridLayout()

        grid.addWidget(create_central_labels("Shipments Summary"), 0, 0, 1, 4)

        labels_text = ["Id", "shipment # ", "AWB #"]
        labels_list = []
        for label in labels_text:
            labels_list.append(create_central_labels(label))
        for i in range(0, len(labels_list) - 1):
            grid.addWidget(labels_list[i], 1, i)

        grid.addWidget(labels_list[2], 1, 2, 1, 2)
        # ----------------------------------------------------------------------------------
        #  **** Now searcing for existing shipments in the database and displaying them
        # ----------------------------------------------------------------------------------
        self.existing_shipment_list_dict = fetch_shipments_list(
            self.db_connection_obj)

        sobj = self.existing_shipment_list_dict

        for j in range(0, len(sobj)):
            grid.addWidget(create_center_data(str(sobj[j]['id'])), j + 2, 0)
            grid.addWidget(create_center_data(str(sobj[j]['number'])), j + 2,
                           1)
            grid.addWidget(create_center_data(str(sobj[j]['awb_no'])), j + 2,
                           2, 1, 2)

        # Make it look organized------------------------------------------------
        for j in range(len(sobj), 22):
            for i in range(0, 3):
                grid.addWidget(create_center_blank(""), j + 1, i)
        # ----------------------------------------------------------
        # Adding the button to add deliverable, edit existing one or delete
        # ----------------------------------------------------------
        j = 21

        self.pb_add = QtGui.QPushButton()
        self.pb_add.setText("+")
        self.pb_add.setStatusTip('Add more shipments')
        self.pb_add.clicked.connect(self.parent.set_add_shipment)
        grid.addWidget(self.pb_add, j, 0)

        self.pb_edit = QtGui.QPushButton()
        self.pb_edit.setText('Edit')
        self.pb_edit.setStatusTip('Edit and existing deliverable')
        self.pb_edit.clicked.connect(self.edit_single_shipment)
        grid.addWidget(self.pb_edit, j, 1)

        self.pb_delete = QtGui.QPushButton()
        self.pb_delete.setText('Delete')
        self.pb_delete.setStatusTip('Delete an existing deliverable')
        self.pb_delete.clicked.connect(self.delete_shipment)
        grid.addWidget(self.pb_delete, j, 2)

        self.pb_home = QtGui.QPushButton()
        self.pb_home.setText('Exit')
        self.pb_home.setStatusTip('Exit and return to Home screen ')
        self.pb_home.clicked.connect(self.parent.show_project_info)
        grid.addWidget(self.pb_home, j, 3)

        self.pb_report = QtGui.QPushButton()
        self.pb_report.setText('Content report')
        self.pb_report.setStatusTip('Show shipment content report')
        self.pb_report.clicked.connect(self.shipment_content_report)
        grid.addWidget(self.pb_report, j + 1, 0, 1, 4)

        self.setLayout(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 __init__(self, parent, id):
        # define the top window

        super(view_single_deliverable_detail, self).__init__(parent=parent)
        self.parent = parent
        self.db_connection_obj = self.parent.db_connection_obj  # use this line to pass the connection object between the parent and the child
        grid = QtGui.QGridLayout()
        # -------------------------------------------
        # add title
        # -------------------------------------------
        grid.addWidget(create_central_labels('Details for the deliverable'), 0,
                       0, 1, 2)
        keys_list = [
            'id',
            'name',
            'class_d',
            'type',
            'media',
            'copies',
            'prod_version',
            'reel_prefix',
            'sgyt_master_status',
            'bin_def_status',
            'trc_def_status',
            'active_status',
            'sgyt',
            'bin_def',
            'trc_def',
        ]
        result = fetch_single_deliverable(self.db_connection_obj, id)
        grid.addWidget(create_central_labels('Existing deliverable details'),
                       0, 0, 1, 2)

        self.id = id
        self.result = result

        for j in range(0, len(keys_list)):
            grid.addWidget(create_center_data(str(keys_list[j])), j + 1, 0)

        for j in range(0, 8):
            grid.addWidget(
                create_left_blank(str(result[keys_list[j]]), "blue"), j + 1, 1)

        for j in range(9, 12):
            if result[str(keys_list[j])] is True:
                grid.addWidget(create_true_label(), j + 1, 1)
            else:
                grid.addWidget(create_false_label(), j + 1, 1)
                if j != 10:
                    grid.addWidget(create_left_blank('No data to show', 'red'),
                                   j + 5, 1)

        path_keys = ['path_sgyt', 'path_bin_def', 'path_trc_def']

        for i in range(0, len(path_keys)):
            grid.addWidget(create_center_data(str(path_keys[i])), i + 16, 0)
            if result[path_keys[i]] is not None:
                grid.addWidget(
                    create_left_blank(str(result[path_keys[i]]), 'blue'),
                    i + 16, 1)
            else:
                grid.addWidget(
                    create_left_blank('No file selected so far', 'red'),
                    i + 16, 1)

        if result['sgyt_master_status'] is True:
            self.pb_show_sgyt = QtGui.QPushButton()
            self.pb_show_sgyt.setText('Show EBCDIC only')
            self.pb_show_sgyt.setStatusTip(
                'Show the DUG segyt file associated with the deliverable')
            self.pb_show_sgyt.clicked.connect(self.show_ebcdic)
            grid.addWidget(self.pb_show_sgyt, 13, 1)

        if result['bin_def_status'] is True:
            self.pb_show_bin = QtGui.QPushButton()
            self.pb_show_bin.setText('Show Bin.def')
            self.pb_show_bin.setStatusTip(
                'Show the DUG segyt file associated with the deliverable')
            self.pb_show_bin.clicked.connect(self.show_bin_def)
            grid.addWidget(self.pb_show_bin, 14, 1)

        if result['trc_def_status'] is True:
            self.pb_show_trc = QtGui.QPushButton()
            self.pb_show_trc.setText('Show Trc.def')
            self.pb_show_trc.setStatusTip(
                'Show the DUG segyt file associated with the deliverable')
            self.pb_show_trc.clicked.connect(self.show_trc_def)
            grid.addWidget(self.pb_show_trc, 15, 1)

        self.pb_exit = QtGui.QPushButton()
        self.pb_exit.setText('Exit')
        self.pb_exit.clicked.connect(self.parent.set_deliverables_window)
        grid.addWidget(self.pb_exit, 19, 0)
        self.setLayout(grid)
    def __init__(self, parent, id):
        # define the top window

        super(edit_single_deliverable, self).__init__(parent=parent)
        self.parent = parent
        self.id = id
        self.db_connection_obj = self.parent.db_connection_obj  # use this line to pass the connection object between the parent and the child
        grid = QtGui.QGridLayout()
        # -------------------------------------------
        # add title
        # -------------------------------------------
        grid.addWidget(create_central_labels('Edit single Deliverable'), 0, 0,
                       1, 2)

        self.db_connection_obj.sess = self.db_connection_obj.Session()
        self.new_deliverable = self.db_connection_obj.sess.query(
            self.db_connection_obj.Deliverables).filter(
                self.db_connection_obj.Deliverables.id == id).first()

        self.result = self.new_deliverable.__dict__

        keys_list = [
            'id', 'name', 'class_d', 'type', 'media', 'copies', 'prod_version',
            'reel_prefix', 'sgyt', 'bin_def', 'trc_def'
        ]
        keys_dict = {}
        keys_dict['id'] = create_center_data(str(self.result['id']))
        keys_dict['name'] = QtGui.QLineEdit()
        class_choice = QtGui.QComboBox()
        class_choice.addItems(deliverable_classes)
        keys_dict['class_d'] = class_choice
        type_choice = QtGui.QComboBox()
        type_choice.addItems(deliverable_type_list)
        keys_dict['type'] = type_choice
        media_choice = QtGui.QComboBox()
        media_choice.addItems(valid_media_list)
        keys_dict['media'] = media_choice
        keys_dict['copies'] = QtGui.QLineEdit()
        keys_dict['prod_version'] = QtGui.QLineEdit()
        keys_dict['reel_prefix'] = QtGui.QLineEdit()
        keys_dict['sgyt'] = QtGui.QLineEdit()
        keys_dict['bin_def'] = QtGui.QLineEdit()
        keys_dict['trc_def'] = QtGui.QLineEdit()

        self.deliverable_def = keys_dict

        pb_sgyt = QtGui.QPushButton()
        pb_sgyt.setText('Select SGYT file')
        pb_sgyt.clicked.connect(self.browse_sgyt)

        pb_bin_def = QtGui.QPushButton()
        pb_bin_def.setText('Select bin.def file')
        pb_bin_def.clicked.connect(self.browse_bin_def)

        pb_trc_def = QtGui.QPushButton()
        pb_trc_def.setText('Select trc.def file')
        pb_trc_def.clicked.connect(self.browse_trc_def)

        for i in range(0, len(keys_list)):
            grid.addWidget(create_central_labels(str(keys_list[i])), i + 1, 0)
            grid.addWidget(keys_dict[keys_list[i]], i + 1, 1)

        grid.addWidget(pb_sgyt, 9, 2)
        grid.addWidget(pb_bin_def, 10, 2)
        grid.addWidget(pb_trc_def, 11, 2)

        j = len(keys_list)

        self.pb_save = QtGui.QPushButton()
        self.pb_save.setText('Update')
        self.pb_save.setStatusTip('Save deliverable to the database')
        self.pb_save.clicked.connect(self.update_deliverable)

        grid.addWidget(self.pb_save, j + 1, 0)

        self.pb_exit = QtGui.QPushButton()
        self.pb_exit.setText('Back')
        self.pb_exit.setStatusTip('Back to main deliverables Menu')
        self.pb_exit.clicked.connect(self.parent.set_deliverables_window)

        grid.addWidget(self.pb_exit, j + 2, 0)

        self.object_to_gui()

        self.setLayout(grid)