Esempio n. 1
0
def show_timfiles(timfiles):
    if len(timfiles):
        print "--"*25
        for timfile in timfiles:
            print colour.cstring("Timfile ID:", underline=True, bold=True) + \
                colour.cstring(" %d" % timfile['timfile_id'], bold=True)
            print "Pulsar name: %s" % timfile['pulsar_name']
            print "Master timfile? %s" % \
                        (((timfile['mtimid'] is not None) and "Yes") or "No")
            print "Last edited by: %s (%s)" % (timfile['real_name'],
                                               timfile['email_address'])
            print "Comments: %s" % timfile['comments']
            print "Date and time timfile was last edited: %s" % \
                timfile['add_time'].isoformat(' ')
            print "Number of TOAs: %d" % timfile['numtoas']
            if timfile['any_replaced'] is not None:
                colour.cprint("Some TOAs are from rawfiles that been "
                              "superseded", 'warning')

            # Show extra information if verbosity is >= 1
            lines = ["First TOA (MJD): %s" % timfile['startmjd'],
                     "Last TOA (MJD): %s" % timfile['endmjd'],
                     "Number of telescopes used: %d" % timfile['numtelescopes'],
                     "Number of observing systems used: %d" % timfile['numobsys']]
            notify.print_info("\n".join(lines), 1)
            print "--"*25
    else:
        raise errors.ToasterError("No timfiles match parameters provided!")
Esempio n. 2
0
 def __call__(self, parser, namespace, values, option_string):
     colour.cprint("Available Manipulators:",
                   bold=True, underline=True)
     for name in sorted(registered_manipulators):
         manip = load_manipulator(name)
         wrapper = textwrap.TextWrapper(subsequent_indent=" "*(len(name)+4))
         print "%s -- %s" % (colour.cstring(name, bold=True), 
                             wrapper.fill(manip.description))
     sys.exit(1)
Esempio n. 3
0
def print_success(msg):
    """Print a success message.

        The message is colourized with the preset 'success' mode.

        Inputs:
            msg: The message to print.

        Outputs:
            None
    """
    colour.cprint(msg, 'success')
    sys.stdout.flush()
Esempio n. 4
0
 def __call__(self, parser, namespace, values, option_string):
     colour.cprint("Available Diagnostics:", \
                     bold=True, underline=True) 
     descwrapper = textwrap.TextWrapper(initial_indent="    ", 
                             subsequent_indent="    ")
     for key in sorted(diagnostics.registered_diagnostics):
         diagcls = diagnostics.get_diagnostic_class(key)
         wrapper = textwrap.TextWrapper(subsequent_indent=" "*(len(key)+4))
         print "%s -- %s" % (colour.cstring(key, bold=True), 
                                 wrapper.fill(diagcls.name))
         if diagcls.description is not None:
             print descwrapper.fill(diagcls.description)
     sys.exit(1)
Esempio n. 5
0
def print_info(msg, level=1):
    """Print an informative message if the current verbosity is
        higher than the 'level' of this message.

        The message will be colourized as 'info'.

        Inputs:
            msg: The message to print.
            level: The verbosity level of the message.
                (Default: 1 - i.e. don't print unless verbosity is on.)

        Outputs:
            None
    """
    if config.cfg.verbosity >= level:
        if config.cfg.excessive_verbosity:
            # Get caller info
            fn, lineno, funcnm = inspect.stack()[1][1:4]
            colour.cprint("INFO (level: %d) [%s:%d - %s(...)]:" %
                          (level, os.path.split(fn)[-1], lineno, funcnm),
                          'infohdr')
            msg = msg.replace('\n', '\n    ')
            colour.cprint("    %s" % msg, 'info')
        else:
            colour.cprint(msg, 'info')
        sys.stdout.flush()
Esempio n. 6
0
def show_procjobs(procjobs):
    print "--" * 25
    for procjob in procjobs:
        print colour.cstring("Process Id:", underline=True, bold=True) + colour.cstring(
            " %d" % procjob.process_id, bold=True
        )
        print "\nPulsar name: %s" % cache.get_pulsarname(procjob.pulsar_id)
        print "Rawfile (ID=%d): %s" % (procjob.rawfile_id, procjob.rawfn)
        if procjob.replacement_rawfile_id is not None:
            colour.cprint("Rawfile has been superseded by rawfile_id=%d" % procjob.replacement_rawfile_id, "warning")
        print "Manipulator: %s" % procjob.manipulator
        print "       Args: %s" % procjob.manipulator_args
        print "Number of freq. chunks: %d" % procjob.nchan
        print "Number of time chunks: %d" % procjob.nsub
        print "Uploaded by: %s (%s)" % (procjob.real_name, procjob.email_address)
        print "Date and time job completed: %s" % procjob.add_time.isoformat(" ")
        if config.cfg.verbosity >= 1:
            lines = ["Template (ID=%d): %s" % (procjob.template_id, procjob.tempfn)]
            if procjob.parfile_id is not None:
                lines.append("Parfile (ID=%d): %s" % (procjob.parfile_id, procjob.parfn))
            else:
                lines.append("No parfile installed during processing.")
            notify.print_info("\n".join(lines), 1)
        print "--" * 25