Beispiel #1
0
def try_read(lcw, _save=True):
    """
    try read from bridge, if key not there, save default value
    :param lcw: string, local codeword
    :param _save: boolean, if not in bridge then save
    :return: various
    """
    global bridge_client, cw

    temp_cw, default = get_cw_default(lcw)
    tmp_str = bridge_client.get(temp_cw)

    if support.is_empty(tmp_str):
        tmp = default
        if _save:
            bridge_client.put(temp_cw, str(tmp))
    else:
        if type(default) is int:
            try:
                tmp = int(tmp_str)
            except ValueError:
                tmp = default
        else:
            tmp = tmp_str
    return tmp
Beispiel #2
0
def try_read(lcw, _save=True):
    """
    try read from bridge, if key not there, save default value
    :param lcw: string, local codeword
    :param _save: boolean, if not in bridge then save
    :return: various
    """
    global bridge_client, cw

    temp_cw, default = get_cw_default(lcw)
    tmp_str = bridge_client.get(temp_cw)

    if support.is_empty(tmp_str):
        tmp = default
        if _save:
            bridge_client.put(temp_cw, str(tmp))
    else:
        if type(default) is int:
            try:
                tmp = int(tmp_str)
            except ValueError:
                tmp = default
        else:
            tmp = tmp_str
    return tmp
Beispiel #3
0
 def do_import(self):
     section_name = 'discus'
     line = 'continue'
     if is_empty(self.lst_external.curselection()):
         i = 0
     else:
         if self.filename.get() != 'Filename undefined':
             if int(self.lst_external.curselection()[0]) == 0:
                 line = 'import cif, ' + str(self.filename.get())
     suite.execute_command(section_name, line)
Beispiel #4
0
 def discus_help(self, user):
     # Remember old states
     fourmenu_state = self.b_fourmenu.state()
     # Temporarily turn off
     turn_off(self.b_strumenu, self.b_fourmenu, self.b_cmd, self.b_macro)
     control_label(self, 'help', 'discus', 2)
     # Activate for current user type
     if user.get() == 0:
         turn_on(self.b_strumenu, self.b_macro)
     else:
         turn_on(self.b_strumenu, self.b_cmd, self.b_macro)
     # For all users return menus to previous state if active
     if is_empty(fourmenu_state):
         turn_on(self.b_fourmenu)
Beispiel #5
0
 def convert_external(self, eff=None, event=0):
     if is_empty(self.lst_external.curselection()):
         self.typestring = 'CIF files'
         self.typeext = '*.cif *.CIF'
     else:
         if int(self.lst_external.curselection()[0]) == 0:
             self.typestring = 'CIF files'
             self.typeext = '*.cif *.CIF'
         elif int(self.lst_external.curselection()[0]) == 1:
             self.typestring = 'SHELX files'
             self.typeext = '*.ins *.res *.INS *.RES'
         elif int(self.lst_external.curselection()[0]) == 2:
             self.typestring = 'RMCprofile files'
             self.typeext = '*.cssr *.CSSR'
         elif int(self.lst_external.curselection()[0]) == 3:
             self.typestring = 'CMAKER files'
             self.typeext = '*.txt *.TXT'
Beispiel #6
0
 def process_msg(self):
     """
     Process message queue
     :return: nothing
     """
     while len(self.var.msgQ) > 0:
         logmsg.update("Message queue: " + str(self.var.msgQ), 'D')
         wait_cycle = False
         if support.is_yun():
             # this is waiting routine to ensure that msg queue is processed by 32u4 part
             tmp_br = bridge.get("msg")
             if not support.is_empty(tmp_br):
                 time.sleep(self.setup.timeout)
                 wait_cycle = True
         if not wait_cycle:
             to_send = self.var.msgQ.pop()
             logmsg.update("Sending message [" + str(to_send) + "]", 'D')
             # if we are going to reset, save bridge file
             if to_send == "R":
                 bridge.save(self.setup.bridge_file)
             if support.is_yun():
                 # signal to 32u4 that we have something to process
                 bridge.put("msg", to_send)
             elif support.is_rpi():
                 if to_send == "H":
                     # TBI RPI
                     # uncomment line below for RPi
                     # action.do(True)
                     pass
                 elif to_send == "S":
                     # TBI RPI
                     # uncomment line below for RPi
                     # action.do(False)
                     pass
             elif support.is_win():
                 # insert windows code here
                 # print "nt"
                 logmsg.update("Processing message on Windows: " +
                               str(to_send))
Beispiel #7
0
 def process_msg(self):
     """
     Process message queue
     :return: nothing
     """
     while len(self.var.msgQ) > 0:
         logmsg.update("Message queue: " + str(self.var.msgQ), 'D')
         wait_cycle = False
         if support.is_yun():
             # this is waiting routine to ensure that msg queue is processed by 32u4 part
             tmp_br = bridge.get("msg")
             if not support.is_empty(tmp_br):
                 time.sleep(self.setup.timeout)
                 wait_cycle = True
         if not wait_cycle:
             to_send = self.var.msgQ.pop()
             logmsg.update("Sending message [" + str(to_send) + "]", 'D')
             # if we are going to reset, save bridge file
             if to_send == "R":
                 bridge.save(self.setup.bridge_file)
             if support.is_yun():
                 # signal to 32u4 that we have something to process
                 bridge.put("msg", to_send)
             elif support.is_rpi():
                 if to_send == "H":
                     # TBI RPI
                     # uncomment line below for RPi
                     # action.do(True)
                     pass
                 elif to_send == "S":
                     # TBI RPI
                     # uncomment line below for RPi
                     # action.do(False)
                     pass
             elif support.is_win():
                 # insert windows code here
                 # print "nt"
                 logmsg.update("Processing message on Windows: " + str(to_send))
Beispiel #8
0
            label = ''
            for m in matches:
                label += f'{m} + '
            label = label[:-3]
            plt.annotate(label, (x,y), fontsize=8)
        # plt.xlabel('Value')
    
    scrub_col = col.replace('/', '-') # replace slashes with dashes to protect filepath
    fig_name = os.path.join(mono_folder, f'{scrub_col}.png')
    plt.savefig(fig_name)
    plt.close()

    print('Evaluating completeness')
    for i, row in df.iterrows():
        # explicit comparisons of bools needed because we are exploiting the ability to mix key datatypes
        if not is_empty(row[col]):
            has_data = True
            # print('Is not empty')
        elif single_cols[col] is False:
            has_data = True
            # print('Does not need data')
        elif single_cols[col] is True: # if data is required
            has_data = False
            # print('Does not have data and deffo needs it')
        else: # if we get here, need to see if the companion columns are filled
            # if all companion columns are filled, then data is required
            companions = [row[c] for c in single_cols[col]]
            has_required_companions = all([not is_empty(row[c]) for c in single_cols[col]])
            has_data = not has_required_companions
            
        if not has_data: