Exemple #1
0
def main(argv):
    """
    pullover's entry point.

    :param list(str) argv: Command-line arguments, with the program in position
                           0.
    """

    args = _parse_argv(argv)

    # sort out logging output and level
    level = util.log_level_from_vebosity(args.verbosity)
    root = logging.getLogger()
    root.setLevel(level)
    handler = logging.StreamHandler(sys.stdout)
    handler.setLevel(level)
    handler.setFormatter(logging.Formatter('%(levelname)s %(message)s'))
    root.addHandler(handler)

    logger.debug(args)

    message = Message(args.message, args.title, args.timestamp, args.url,
                      args.url_title, args.priority)
    app = Application(args.app)
    user = User(args.user)
    response = message.send(app, user)
    if response.ok:
        print(response.id)
        return 0

    util.print_error(os.linesep.join(response.errors))
    return 1
Exemple #2
0
 def test_default(self):
     self.assertEqual(util.log_level_from_vebosity(None), logging.DEBUG)
Exemple #3
0
 def test_info(self):
     self.assertEqual(util.log_level_from_vebosity(1), logging.INFO)
Exemple #4
0
 def test_debug(self):
     self.assertEqual(util.log_level_from_vebosity(2), logging.DEBUG)
Exemple #5
0
 def test_warning(self):
     self.assertEqual(util.log_level_from_vebosity(0), logging.WARNING)