Exemplo n.º 1
0
def report(text, level=None, slack=False):
    '''Print a string to:
      * the log file
      * the screen
      * the BMM beamtime slack channel

    Report level decorations  on screen:

      * 'error' (red)
      * 'warning' (yellow)
      * 'info' (brown)
      * 'url' (undecorated)
      * 'bold' (bright white)
      * 'verbosebold' (bright cyan)
      * 'list' (cyan)
      * 'disconnected' (purple)
      * 'whisper' (gray)

    not matching a report level will be undecorated
    '''
    BMMuser = user_ns['BMMuser']
    BMM_log_info(text)
    if color:  # test that color is sensible...
        if level == 'error':
            print(error_msg(text))
        elif level == 'warning':
            print(warning_msg(text))
        elif level == 'info':
            print(info_msg(text))
        elif level == 'url':
            print(url_msg(text))
        elif level == 'bold':
            print(bold_msg(text))
        elif level == 'verbosebold':
            print(verbosebold_msg(text))
        elif level == 'disconnected':
            print(disconnected_msg(text))
        elif level == 'list':
            print(list_msg(text))
        elif level == 'whisper':
            print(whisper(text))
        else:
            print(text)
    else:
        print(text)
    if BMMuser.use_slack and slack:
        post_to_slack(text)
Exemplo n.º 2
0
 def status(self):
     text = '\n  %s is %s\n\n' % (self.name, self.prefix)
     for signal in status_list.keys():
         sig = signal.lower()
         try:
             suffix = getattr(self, sig).pvname.replace(self.prefix, '')
             string = getattr(self, sig).enum_strs[getattr(self, sig).get()]
             if signal != 'asscs':
                 if getattr(self, sig).get() != status_list[signal]:
                     string = verbosebold_msg('%-19s' % string)
             #text += '  %-26s : %-19s  %s   %s \n' % (getattr(self, sig+'_desc').get(),
             #                                         string,
             #                                         bold_msg(getattr(self, sig).get()),
             #                                         whisper(suffix))
             text += '  %-19s  %s   %s \n' % (
                 string, bold_msg(getattr(self,
                                          sig).get()), whisper(suffix))
         except:
             pass
     boxedtext('%s status signals' % self.name, text, 'green')
Exemplo n.º 3
0
def initialize_workspace():
    '''Perform a series of checks to see if the workspace on this computer
    is set up as expected by the BMM data collection profile.  This
    includes checks that:
      * various directories exist
      * NAS1 is mounted
      * a redis server is available
      * certain git repositories are cloned onto this computer
      * authentication files for Slack are available.
      * the public key for xf06bm@xf06bm-ws1 is available or that this is xf06bm-ws1

    For most checks, a failure triggers a corrective action, if
    possible.  Some failures print a warning to screen, with no
    corrective action.

    '''
    print(verbosebold_msg('Checking workspace on this computer ...'))
    initialize_data_directories()
    initialize_beamline_configuration()
    initialize_nas()
    initialize_secrets()
    initialize_redis()
    #initialize_gdrive()
    initialize_ssh()