summaryrefslogtreecommitdiff
path: root/portato/__init__.py
blob: 4b6a80834ccbc3378dc1b0016d59bd8a0b29969d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# -*- coding: utf-8 -*-
#
# File: portato/__init__.py
# This file is part of the Portato-Project, a graphical portage-frontend.
#
# Copyright (C) 2006-2007 René 'Necoro' Neumann
# This is free software.  You may redistribute copies of it under the terms of
# the GNU General Public License version 2.
# There is NO WARRANTY, to the extent permitted by law.
#
# Written by René 'Necoro' Neumann <necoro@necoro.net>

from __future__ import absolute_import

import logging
import sys
import os

class OutputFormatter (logging.Formatter):

	colors = { 
			"blue"	: 34,
			"green"	: 32,
			"red"	: 31,
			"yellow": 33
			}

	def __init__(self, *args, **kwargs):
		logging.Formatter.__init__(self, *args, **kwargs)

		for key, value in self.colors.iteritems():
			self.colors[key] = "\x1b[01;%02dm*\x1b[39;49;00m" % value

	def format (self, record):
		string = logging.Formatter.format(self, record)
		color = None

		if os.isatty(sys.stderr.fileno()):
			if record.levelno <= logging.DEBUG:
				color = self.colors["blue"]
			elif record.levelno <= logging.INFO:
				color = self.colors["green"]
			elif record.levelno <= logging.WARNING:
				color = self.colors["yellow"]
			else:
				color = self.colors["red"]
		else:
			color = "%s:" % record.levelname

		return "%s %s" % (color, string)

# set the whole logging stuff
formatter = OutputFormatter("%(message)s (%(filename)s:%(lineno)s)")

handler = logging.StreamHandler()
handler.setFormatter(formatter)
logging.getLogger("portatoLogger").addHandler(handler)
logging.getLogger("portatoLogger").setLevel(logging.DEBUG)
logging.getLogger("portatoLogger").propagate = False

__listener = None

def get_listener():
	global __listener
	if __listener is None:
		from .plistener import PListener
		__listener = PListener()
	
	return __listener
2012-09-04No echo mode.Jason A. Donenfeld2-16/+42 Add a --no-echo flag to the insert operation so that the password isn't echoed when entering it. This requires the user to echo the password twice for confirmation. Reported-by: Dominic Lüchinger <d.luechinger@snowgarden.ch> 2012-09-04Properly quote the path too.Jason A. Donenfeld1-1/+1 2012-09-04Allow passwords having spaces to go unbroken to the clipboard.Bernardo Freitas Paulo da Costa1-1/+1 This also prevents showing the second <word> of the password in the prompt. 2012-09-04Separate out the massive git example.Jason A. Donenfeld1-10/+14 2012-09-04Prepare for debianification.1.0Jason A. Donenfeld9-4/+60 2012-09-03Fix readme typo.Jason A. Donenfeld1-1/+1 2012-09-03Show program name properly in error message.Jason A. Donenfeld1-1/+1 2012-09-03Move examples into manpage.Jason A. Donenfeld4-93/+224 2012-09-03Make into a real project.Jason A. Donenfeld8-5/+173 2012-09-03Support pass gitJason A. Donenfeld2-1/+15 2012-08-31Add remove synonyms.Jason A. Donenfeld1-2/+2 2012-08-31Use basename in usage.Jason A. Donenfeld1-2/+1 2012-08-19now using gpg_id as a varMatthew Ramirez1-2/+2 2012-08-07Forty five seconds.Jason A. Donenfeld1-1/+1 2012-08-06Deal with klipper and new lines.Jason A. Donenfeld1-3/+19 2012-08-06Update examples.Jason A. Donenfeld1-7/+7 2012-08-06Update readme.Jason A. Donenfeld1-11/+13 2012-08-06Be slicker and more like git.Jason A. Donenfeld1-114/+173