def __init__(self, process_info=None): """ Define simple collector parser and its command line options. To begin, we just ask for a kTBS root which is mandatory. """ self._parser = ArgumentParser(description="Fill a stored trace with \ browser history items as \ obsels.") self._parser.add_argument("-f", "--file", nargs="?", const=FIREFOX_HISTORY, default=FIREFOX_HISTORY, help="File containings the sqlite data to \ parse. Default is %s" % FIREFOX_HISTORY) self._parser.add_argument("-r", "--root", nargs="?", const=KTBS_ROOT, default=KTBS_ROOT, help="Enter the uri of the kTBS root. \ Default is %s" % KTBS_ROOT) self._parser.add_argument("-o", "--origin", nargs="?", const=TRACE_ORIGIN, default=TRACE_ORIGIN, help="Enter the trace origin. Default is \ %s" % TRACE_ORIGIN) self._parser.add_argument("-l", "--limit", nargs="?", type=int, const=NB_MAX_ITEMS, default=NB_MAX_ITEMS, help="Enter the maximun number of items to \ collect. Default is %s" % NB_MAX_ITEMS) self._parser.add_argument("-p", "--profile", action="store_true", help="Profile current code") self._parser.add_argument("-s", "--stats", action="store_true", help="Mesure execution time") self._parser.add_argument("-v", "--verbose", action="store_true", help="Display print messages") self._args = self._parser.parse_args() self.display("Parsed with argparse: %s" % str(self._args)) if self._args.stats: # To get process information without callback mechanism my_PID = os.getpid() self.process_info = ProcessInfo(my_PID)