1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
| #!/usr/bin/python
# -*- coding: utf-8 -*-
from Tkinter import *
from tkMessageBox import *
from tkFileDialog import askdirectory, askopenfilename, asksaveasfilename
import sys, os, xlrd, xlwt, time, logging, datetime
VERSION = 'v0.97'
def mkdir_with_mode(directory, mode=777):
"""
Create a directory with requested rights (mode)
:param directory:
:param mode: unix mode
:return:
"""
if not os.path.isdir(directory):
oldmask = os.umask(000)
os.makedirs(directory, mode)
os.umask(oldmask)
def my_logger(my_message):
"""
Permits to log message in the console and in a file
:param my_message: log message
:return: nothing
"""
print my_message
logging.info(my_message)
class Window:
def __init__(self, master):
self.pos_fmc_dic = dict()
self.pos_pin_alloc_dic = dict()
self.test_objective_list = list()
self.test_procedure_list = list()
# Values to be erased, value set to debug purpose
self.fmd_folder = ''
self.pin_alloc_file = ''
self.rbct_to_files = ''
self.output_file_name = 'Interfaces.xlsx'
self.crdc_cpiom = IntVar()
Label(root, text="Choose EQUIP1 or EQUIP2: ", font='Helvetica 12 bold').grid(row=1, column=0, padx=10, pady=10)
self.check_button1 = Radiobutton(root, text='EQUIP1', variable=self.crdc_cpiom, value=1, command=self.test1())
self.check_button1.grid(row=1, column=2, sticky=W + E, padx=10, pady=10)
self.check_button2 = Radiobutton(root, text='EQUIP2', variable=self.crdc_cpiom, value=2, command=self.test2())
self.check_button2.grid(row=1, column=3, sticky=W + E, padx=10, pady=10)
Label(root, text="INPUTS:", font='Helvetica 12 bold').grid(row=2, column=0, padx=10, pady=10)
Label(root, text="FMD folder \n(Files name must contain the string 'FMD_<pos>')").grid(row=3, column=0, padx=10,
pady=10)
Label(root, text="Pin alloc file/folder").grid(row=4, column=0, padx=10, pady=10)
Label(root, text="EQUIP1 Test objective and procedures").grid(row=5, column=0, padx=10, pady=10)
Label(root, text="RBCT output table:", font='Helvetica 12 bold').grid(row=6, column=0, padx=10, pady=10)
self.cbutton = Button(root, text=" Go Process! ", font='Helvetica 12 bold', command=self.process)
self.cbutton.grid(row=11, column=4, sticky=W + E, padx=10, pady=10)
self.bbutton = Button(root, text="SELECT FMD folder", command=self.browse_fmd)
self.bbutton.grid(row=3, column=3, padx=10, pady=10)
self.fmd_label = Label(root, text=self.fmd_folder).grid(row=3, column=4, padx=10, pady=10)
self.cbutton.grid(row=12, column=3, sticky=W + E, padx=10, pady=10)
self.bbutton = Button(root, text="SELECT Pin alloc folder/file ", command=self.browse_pin_alloc)
self.bbutton.grid(row=4, column=3, padx=10, pady=10)
self.pin_alloc_label = Label(root, text=self.pin_alloc_file).grid(row=4, column=4, padx=10, pady=10)
self.cbutton.grid(row=13, column=2, sticky=W + E, padx=10, pady=10)
self.bbutton = Button(root, text="RBCT Test objectives file ", command=self.browse_test_objectives)
self.bbutton.grid(row=5, column=3, padx=10, pady=10)
self.rbct_to_label = Label(root, text=self.rbct_to_files).grid(row=5, column=4, padx=10, pady=10)
self.cbutton.grid(row=14, column=2, sticky=W + E, padx=10, pady=10)
self.bbutton = Button(root, text="Select Output file name ", command=self.browser_output_file)
self.bbutton.grid(row=7, column=3, padx=10, pady=10)
self.output_file_label = Label(root, text='Default =' + self.output_file_name).grid(row=7, column=4, padx=10,
pady=10)
log_date = datetime.datetime.now().strftime('%Y_%m_%d_%H_%M')
log_file = 'logfile_' + log_date + '.txt'
if not (os.path.exists('logs')):
mkdir_with_mode('logs', 777)
logging.basicConfig(filename='logs/' + log_file, level=logging.DEBUG,
format='%(asctime)s -- %(levelname)s -- %(message)s')
def test1(self):
my_logger('test1')
def test2(self):
my_logger('test2')
def process(self):
my_logger('method process')
def browse_fmd(self):
my_logger('method browse_fmd')
def browse_pin_alloc(self):
my_logger('method browse_pin_alloc')
def browse_test_objectives(self):
my_logger('method browse TO')
def browser_output_file(self):
my_logger('method browser_output_file')
if __name__ == "__main__":
# main(sys.argv[1:])
root = Tk()
root.title(' Interface ' + VERSION)
window = Window(root)
root.geometry('1350x380')
root.mainloop() |