Show More
@@ -123,7 +123,6 b' class LdapSettingsController(BaseControl' | |||
|
123 | 123 | except formencode.Invalid, errors: |
|
124 | 124 | e = errors.error_dict or {} |
|
125 | 125 | |
|
126 | ||
|
127 | 126 | return htmlfill.render( |
|
128 | 127 | render('admin/ldap/ldap.html'), |
|
129 | 128 | defaults=errors.value, |
@@ -248,6 +248,8 b' class FilesController(BaseRepoController' | |||
|
248 | 248 | revision='tip')) |
|
249 | 249 | |
|
250 | 250 | try: |
|
251 | # decoding here will force that we have proper encoded values | |
|
252 | # in any other case this will throw exceptions and deny commit | |
|
251 | 253 | content = content.encode('utf8') |
|
252 | 254 | message = message.encode('utf8') |
|
253 | 255 | path = f_path.encode('utf8') |
@@ -263,7 +265,6 b' class FilesController(BaseRepoController' | |||
|
263 | 265 | except Exception, e: |
|
264 | 266 | log.error(traceback.format_exc()) |
|
265 | 267 | h.flash(_('Error occurred during commit'), category='error') |
|
266 | raise | |
|
267 | 268 | return redirect(url('changeset_home', |
|
268 | 269 | repo_name=c.repo_name, revision='tip')) |
|
269 | 270 |
@@ -24,7 +24,6 b'' | |||
|
24 | 24 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
25 | 25 | |
|
26 | 26 | |
|
27 | ||
|
28 | 27 | def __get_lem(): |
|
29 | 28 | from pygments import lexers |
|
30 | 29 | from string import lower |
@@ -60,12 +59,13 b' def __get_lem():' | |||
|
60 | 59 | # extensions will index it's content |
|
61 | 60 | LANGUAGES_EXTENSIONS_MAP = __get_lem() |
|
62 | 61 | |
|
63 | #Additional mappings that are not present in the pygments lexers | |
|
62 | # Additional mappings that are not present in the pygments lexers | |
|
64 | 63 | # NOTE: that this will overide any mappings in LANGUAGES_EXTENSIONS_MAP |
|
65 | 64 | ADDITIONAL_MAPPINGS = {'xaml': 'XAML'} |
|
66 | 65 | |
|
67 | 66 | LANGUAGES_EXTENSIONS_MAP.update(ADDITIONAL_MAPPINGS) |
|
68 | 67 | |
|
68 | ||
|
69 | 69 | def str2bool(_str): |
|
70 | 70 | """ |
|
71 | 71 | returs True/False value from given string, it tries to translate the |
@@ -82,6 +82,7 b' def str2bool(_str):' | |||
|
82 | 82 | _str = str(_str).strip().lower() |
|
83 | 83 | return _str in ('t', 'true', 'y', 'yes', 'on', '1') |
|
84 | 84 | |
|
85 | ||
|
85 | 86 | def convert_line_endings(temp, mode): |
|
86 | 87 | from string import replace |
|
87 | 88 | #modes: 0 - Unix, 1 - Mac, 2 - DOS |
@@ -98,6 +99,15 b' def convert_line_endings(temp, mode):' | |||
|
98 | 99 | |
|
99 | 100 | |
|
100 | 101 | def detect_mode(line, default): |
|
102 | """ | |
|
103 | Detects line break for given line, if line break couldn't be found | |
|
104 | given default value is returned | |
|
105 | ||
|
106 | :param line: str line | |
|
107 | :param default: default | |
|
108 | :rtype: int | |
|
109 | :return: value of line end on of 0 - Unix, 1 - Mac, 2 - DOS | |
|
110 | """ | |
|
101 | 111 | if line.endswith('\r\n'): |
|
102 | 112 | return 2 |
|
103 | 113 | elif line.endswith('\n'): |
@@ -107,6 +117,7 b' def detect_mode(line, default):' | |||
|
107 | 117 | else: |
|
108 | 118 | return default |
|
109 | 119 | |
|
120 | ||
|
110 | 121 | def generate_api_key(username, salt=None): |
|
111 | 122 | """ |
|
112 | 123 | Generates unique API key for given username,if salt is not given |
@@ -151,7 +162,7 b' def engine_from_config(configuration, pr' | |||
|
151 | 162 | """ |
|
152 | 163 | Custom engine_from_config functions that makes sure we use NullPool for |
|
153 | 164 | file based sqlite databases. This prevents errors on sqlite. |
|
154 | ||
|
165 | ||
|
155 | 166 | """ |
|
156 | 167 | from sqlalchemy import engine_from_config as efc |
|
157 | 168 | from sqlalchemy.pool import NullPool |
@@ -159,8 +170,6 b' def engine_from_config(configuration, pr' | |||
|
159 | 170 | url = configuration[prefix + 'url'] |
|
160 | 171 | |
|
161 | 172 | if url.startswith('sqlite'): |
|
162 | kwargs.update({'poolclass':NullPool}) | |
|
173 | kwargs.update({'poolclass': NullPool}) | |
|
163 | 174 | |
|
164 | 175 | return efc(configuration, prefix, **kwargs) |
|
165 | ||
|
166 |
@@ -3,6 +3,7 b'' | |||
|
3 | 3 | from beaker.cache import CacheManager |
|
4 | 4 | from beaker.util import parse_cache_config_options |
|
5 | 5 | |
|
6 | ||
|
6 | 7 | class Globals(object): |
|
7 | 8 | """Globals acts as a container for objects available throughout the |
|
8 | 9 | life of the application |
@@ -203,7 +203,7 b' def authenticate(username, password):' | |||
|
203 | 203 | password) |
|
204 | 204 | log.debug('Got ldap DN response %s', user_dn) |
|
205 | 205 | |
|
206 | get_ldap_attr = lambda k:ldap_attrs.get(ldap_settings\ | |
|
206 | get_ldap_attr = lambda k: ldap_attrs.get(ldap_settings\ | |
|
207 | 207 | .get(k), [''])[0] |
|
208 | 208 | |
|
209 | 209 | user_attrs = { |
@@ -1,8 +1,15 b'' | |||
|
1 | #!/usr/bin/env python | |
|
2 | # encoding: utf-8 | |
|
3 | # mercurial repository backup manager | |
|
4 | # Copyright (C) 2009-2011 Marcin Kuzminski <marcin@python-works.com> | |
|
1 | # -*- coding: utf-8 -*- | |
|
2 | """ | |
|
3 | rhodecode.lib.backup_manager | |
|
4 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
|
5 | 5 |
|
|
6 | Mercurial repositories backup manager, it allows to backups all | |
|
7 | repositories and send it to backup server using RSA key via ssh. | |
|
8 | ||
|
9 | :created_on: Feb 28, 2010 | |
|
10 | :copyright: (c) 2010 by marcink. | |
|
11 | :license: LICENSE_NAME, see LICENSE_FILE for more details. | |
|
12 | """ | |
|
6 | 13 | # This program is free software: you can redistribute it and/or modify |
|
7 | 14 | # it under the terms of the GNU General Public License as published by |
|
8 | 15 | # the Free Software Foundation, either version 3 of the License, or |
@@ -16,22 +23,18 b'' | |||
|
16 | 23 | # You should have received a copy of the GNU General Public License |
|
17 | 24 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
18 | 25 | |
|
19 | """ | |
|
20 | Created on Feb 28, 2010 | |
|
21 | Mercurial repositories backup manager | |
|
22 | @author: marcink | |
|
23 | """ | |
|
24 | ||
|
26 | import os | |
|
27 | import sys | |
|
25 | 28 | |
|
26 | 29 | import logging |
|
27 | 30 | import tarfile |
|
28 | import os | |
|
29 | 31 | import datetime |
|
30 | import sys | |
|
31 | 32 | import subprocess |
|
33 | ||
|
32 | 34 | logging.basicConfig(level=logging.DEBUG, |
|
33 | 35 | format="%(asctime)s %(levelname)-5.5s %(message)s") |
|
34 | 36 | |
|
37 | ||
|
35 | 38 | class BackupManager(object): |
|
36 | 39 | def __init__(self, repos_location, rsa_key, backup_server): |
|
37 | 40 | today = datetime.datetime.now().weekday() + 1 |
@@ -46,7 +49,6 b' class BackupManager(object):' | |||
|
46 | 49 | logging.info('starting backup for %s', self.repos_path) |
|
47 | 50 | logging.info('backup target %s', self.backup_file_path) |
|
48 | 51 | |
|
49 | ||
|
50 | 52 | def get_id_rsa(self, rsa_key): |
|
51 | 53 | if not os.path.isfile(rsa_key): |
|
52 | 54 | logging.error('Could not load id_rsa key file in %s', rsa_key) |
@@ -69,14 +71,12 b' class BackupManager(object):' | |||
|
69 | 71 | tar.close() |
|
70 | 72 | logging.info('finished backup of mercurial repositories') |
|
71 | 73 | |
|
72 | ||
|
73 | ||
|
74 | 74 | def transfer_files(self): |
|
75 | 75 | params = { |
|
76 | 76 | 'id_rsa_key': self.id_rsa_path, |
|
77 | 'backup_file':os.path.join(self.backup_file_path, | |
|
77 | 'backup_file': os.path.join(self.backup_file_path, | |
|
78 | 78 | self.backup_file_name), |
|
79 | 'backup_server':self.backup_server | |
|
79 | 'backup_server': self.backup_server | |
|
80 | 80 | } |
|
81 | 81 | cmd = ['scp', '-l', '40000', '-i', '%(id_rsa_key)s' % params, |
|
82 | 82 | '%(backup_file)s' % params, |
@@ -85,13 +85,10 b' class BackupManager(object):' | |||
|
85 | 85 | subprocess.call(cmd) |
|
86 | 86 | logging.info('Transfered file %s to %s', self.backup_file_name, cmd[4]) |
|
87 | 87 | |
|
88 | ||
|
89 | 88 | def rm_file(self): |
|
90 | 89 | logging.info('Removing file %s', self.backup_file_name) |
|
91 | 90 | os.remove(os.path.join(self.backup_file_path, self.backup_file_name)) |
|
92 | 91 | |
|
93 | ||
|
94 | ||
|
95 | 92 | if __name__ == "__main__": |
|
96 | 93 | |
|
97 | 94 | repo_location = '/home/repo_path' |
@@ -15,6 +15,7 b' from rhodecode.model import meta' | |||
|
15 | 15 | from rhodecode.model.scm import ScmModel |
|
16 | 16 | from rhodecode import BACKENDS |
|
17 | 17 | |
|
18 | ||
|
18 | 19 | class BaseController(WSGIController): |
|
19 | 20 | |
|
20 | 21 | def __before__(self): |
@@ -36,7 +37,7 b' class BaseController(WSGIController):' | |||
|
36 | 37 | # the request is routed to. This routing information is |
|
37 | 38 | # available in environ['pylons.routes_dict'] |
|
38 | 39 | try: |
|
39 |
#putting this here makes sure that we update permissions e |
|
|
40 | # putting this here makes sure that we update permissions each time | |
|
40 | 41 | api_key = request.GET.get('api_key') |
|
41 | 42 | user_id = getattr(session.get('rhodecode_user'), 'user_id', None) |
|
42 | 43 | self.rhodecode_user = c.rhodecode_user = AuthUser(user_id, api_key) |
@@ -66,7 +67,8 b' class BaseRepoController(BaseController)' | |||
|
66 | 67 | r, dbrepo = self.scm_model.get(c.repo_name, retval='repo') |
|
67 | 68 | |
|
68 | 69 | if r is not None: |
|
69 |
c.repository_followers = |
|
|
70 | c.repository_followers = \ | |
|
71 | self.scm_model.get_followers(c.repo_name) | |
|
70 | 72 | c.repository_forks = self.scm_model.get_forks(c.repo_name) |
|
71 | 73 | else: |
|
72 | 74 | c.repository_followers = 0 |
@@ -74,6 +76,6 b' class BaseRepoController(BaseController)' | |||
|
74 | 76 | |
|
75 | 77 | # Since RhodeCode uses heavy memory caching we make a deepcopy |
|
76 | 78 | # of object taken from cache. This way we lose reference to cached |
|
77 |
# instance in memory and keep it relatively small even for |
|
|
79 | # instance in memory and keep it relatively small even for | |
|
78 | 80 | # very large number of changesets |
|
79 | 81 | c.rhodecode_repo = copy.copy(r) |
@@ -9,14 +9,15 b' COLOR_SEQ = "\\033[1;%dm"' | |||
|
9 | 9 | BOLD_SEQ = "\033[1m" |
|
10 | 10 | |
|
11 | 11 | COLORS = { |
|
12 |
'CRITICAL': MAGENTA, |
|
|
13 |
'ERROR': RED, |
|
|
14 |
'WARNING': CYAN, |
|
|
15 |
'INFO': GREEN, |
|
|
16 |
'DEBUG': BLUE, |
|
|
17 |
'SQL' |
|
|
12 | 'CRITICAL': MAGENTA, | |
|
13 | 'ERROR': RED, | |
|
14 | 'WARNING': CYAN, | |
|
15 | 'INFO': GREEN, | |
|
16 | 'DEBUG': BLUE, | |
|
17 | 'SQL': YELLOW | |
|
18 | 18 | } |
|
19 | 19 | |
|
20 | ||
|
20 | 21 | def one_space_trim(s): |
|
21 | 22 | if s.find(" ") == -1: |
|
22 | 23 | return s |
@@ -24,6 +25,7 b' def one_space_trim(s):' | |||
|
24 | 25 | s = s.replace(' ', ' ') |
|
25 | 26 | return one_space_trim(s) |
|
26 | 27 | |
|
28 | ||
|
27 | 29 | def format_sql(sql): |
|
28 | 30 | sql = sql.replace('\n', '') |
|
29 | 31 | sql = one_space_trim(sql) |
@@ -43,6 +45,7 b' def format_sql(sql):' | |||
|
43 | 45 | .replace('DELETE', '\n\tDELETE') |
|
44 | 46 | return sql |
|
45 | 47 | |
|
48 | ||
|
46 | 49 | class ColorFormatter(logging.Formatter): |
|
47 | 50 | |
|
48 | 51 | def __init__(self, *args, **kwargs): |
@@ -1,8 +1,14 b'' | |||
|
1 | #!/usr/bin/env python | |
|
2 | # encoding: utf-8 | |
|
3 | # Custom Exceptions modules | |
|
4 | # Copyright (C) 2009-2011 Marcin Kuzminski <marcin@python-works.com> | |
|
5 | # | |
|
1 | # -*- coding: utf-8 -*- | |
|
2 | """ | |
|
3 | rhodecode.lib.exceptions | |
|
4 | ~~~~~~~~~~~~~~~~~~~~~~~~ | |
|
5 | ||
|
6 | Set of custom exceptions used in RhodeCode | |
|
7 | ||
|
8 | :created_on: Nov 17, 2010 | |
|
9 | :copyright: (c) 2010 by marcink. | |
|
10 | :license: LICENSE_NAME, see LICENSE_FILE for more details. | |
|
11 | """ | |
|
6 | 12 | # This program is free software: you can redistribute it and/or modify |
|
7 | 13 | # it under the terms of the GNU General Public License as published by |
|
8 | 14 | # the Free Software Foundation, either version 3 of the License, or |
@@ -15,16 +21,27 b'' | |||
|
15 | 21 | # |
|
16 | 22 | # You should have received a copy of the GNU General Public License |
|
17 | 23 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
18 | """ | |
|
19 | Created on Nov 17, 2010 | |
|
20 | Custom Exceptions modules | |
|
21 | @author: marcink | |
|
22 | """ | |
|
24 | ||
|
25 | ||
|
26 | class LdapUsernameError(Exception): | |
|
27 | pass | |
|
28 | ||
|
29 | ||
|
30 | class LdapPasswordError(Exception): | |
|
31 | pass | |
|
32 | ||
|
23 | 33 | |
|
24 |
class Ldap |
|
|
25 | class LdapPasswordError(Exception):pass | |
|
26 | class LdapConnectionError(Exception):pass | |
|
27 | class LdapImportError(Exception):pass | |
|
34 | class LdapConnectionError(Exception): | |
|
35 | pass | |
|
36 | ||
|
37 | ||
|
38 | class LdapImportError(Exception): | |
|
39 | pass | |
|
28 | 40 | |
|
29 | class DefaultUserException(Exception):pass | |
|
30 |
class User |
|
|
41 | ||
|
42 | class DefaultUserException(Exception): | |
|
43 | pass | |
|
44 | ||
|
45 | ||
|
46 | class UserOwnsReposException(Exception): | |
|
47 | pass |
@@ -32,6 +32,7 b' from mercurial.node import nullrev' | |||
|
32 | 32 | from rhodecode.lib import helpers as h |
|
33 | 33 | from rhodecode.lib.utils import action_logger |
|
34 | 34 | |
|
35 | ||
|
35 | 36 | def repo_size(ui, repo, hooktype=None, **kwargs): |
|
36 | 37 | """Presents size of repository after push |
|
37 | 38 | |
@@ -63,6 +64,7 b' def repo_size(ui, repo, hooktype=None, *' | |||
|
63 | 64 | sys.stdout.write('Repository size .hg:%s repo:%s total:%s\n' \ |
|
64 | 65 | % (size_hg_f, size_root_f, size_total_f)) |
|
65 | 66 | |
|
67 | ||
|
66 | 68 | def log_pull_action(ui, repo, **kwargs): |
|
67 | 69 | """Logs user last pull action |
|
68 | 70 | |
@@ -79,6 +81,7 b' def log_pull_action(ui, repo, **kwargs):' | |||
|
79 | 81 | |
|
80 | 82 | return 0 |
|
81 | 83 | |
|
84 | ||
|
82 | 85 | def log_push_action(ui, repo, **kwargs): |
|
83 | 86 | """Maps user last push action to new changeset id, from mercurial |
|
84 | 87 |
@@ -1,13 +1,16 b'' | |||
|
1 |
import os |
|
|
1 | import os | |
|
2 | 2 | import sys |
|
3 | import time | |
|
4 | import errno | |
|
5 | ||
|
3 | 6 | from warnings import warn |
|
4 | 7 | from multiprocessing.util import Finalize |
|
5 | import errno | |
|
6 | 8 | |
|
7 | 9 | from rhodecode import __platform__, PLATFORM_WIN |
|
8 | 10 | |
|
9 | 11 | if __platform__ in PLATFORM_WIN: |
|
10 | 12 | import ctypes |
|
13 | ||
|
11 | 14 | def kill(pid): |
|
12 | 15 | """kill function for Win32""" |
|
13 | 16 | kernel32 = ctypes.windll.kernel32 |
@@ -17,7 +20,9 b' if __platform__ in PLATFORM_WIN:' | |||
|
17 | 20 | else: |
|
18 | 21 | kill = os.kill |
|
19 | 22 | |
|
20 | class LockHeld(Exception):pass | |
|
23 | ||
|
24 | class LockHeld(Exception): | |
|
25 | pass | |
|
21 | 26 | |
|
22 | 27 | |
|
23 | 28 | class DaemonLock(object): |
@@ -34,8 +39,9 b' class DaemonLock(object):' | |||
|
34 | 39 | def __init__(self, file=None, callbackfn=None, |
|
35 | 40 | desc='daemon lock', debug=False): |
|
36 | 41 | |
|
37 |
self.pidfile = file if file else os.path.join( |
|
|
38 |
|
|
|
42 | self.pidfile = file if file else os.path.join( | |
|
43 | os.path.dirname(__file__), | |
|
44 | 'running.lock') | |
|
39 | 45 | self.callbackfn = callbackfn |
|
40 | 46 | self.desc = desc |
|
41 | 47 | self.debug = debug |
@@ -52,9 +58,10 b' class DaemonLock(object):' | |||
|
52 | 58 | print 'leck held finilazing and running lock.release()' |
|
53 | 59 | lock.release() |
|
54 | 60 | |
|
55 | ||
|
56 | 61 | def lock(self): |
|
57 | """locking function, if lock is present it will raise LockHeld exception | |
|
62 | """ | |
|
63 | locking function, if lock is present it | |
|
64 | will raise LockHeld exception | |
|
58 | 65 | """ |
|
59 | 66 | lockname = '%s' % (os.getpid()) |
|
60 | 67 | if self.debug: |
@@ -75,8 +82,8 b' class DaemonLock(object):' | |||
|
75 | 82 | pidfile.close() |
|
76 | 83 | |
|
77 | 84 | if self.debug: |
|
78 |
print 'lock file present running_pid: %s, |
|
|
79 | % running_pid | |
|
85 | print ('lock file present running_pid: %s, ' | |
|
86 | 'checking for execution') % running_pid | |
|
80 | 87 | # Now we check the PID from lock file matches to the current |
|
81 | 88 | # process PID |
|
82 | 89 | if running_pid: |
@@ -84,7 +91,8 b' class DaemonLock(object):' | |||
|
84 | 91 | kill(running_pid, 0) |
|
85 | 92 | except OSError, exc: |
|
86 | 93 | if exc.errno in (errno.ESRCH, errno.EPERM): |
|
87 |
print "Lock File is there but |
|
|
94 | print ("Lock File is there but" | |
|
95 | " the program is not running") | |
|
88 | 96 | print "Removing lock file for the: %s" % running_pid |
|
89 | 97 | self.release() |
|
90 | 98 | else: |
@@ -122,6 +130,7 b' class DaemonLock(object):' | |||
|
122 | 130 | def makelock(self, lockname, pidfile): |
|
123 | 131 | """ |
|
124 | 132 | this function will make an actual lock |
|
133 | ||
|
125 | 134 | :param lockname: acctual pid of file |
|
126 | 135 | :param pidfile: the file to write the pid in |
|
127 | 136 | """ |
@@ -8,15 +8,16 b' import threading' | |||
|
8 | 8 | |
|
9 | 9 | from StringIO import StringIO |
|
10 | 10 | |
|
11 | ||
|
11 | 12 | class ProfilingMiddleware(object): |
|
12 | 13 | def __init__(self, app): |
|
13 | 14 | self.lock = threading.Lock() |
|
14 | 15 | self.app = app |
|
15 | 16 | |
|
16 | ||
|
17 | 17 | def __call__(self, environ, start_response): |
|
18 | 18 | with self.lock: |
|
19 | 19 | profiler = cProfile.Profile() |
|
20 | ||
|
20 | 21 | def run_app(*a, **kw): |
|
21 | 22 | self.response = self.app(environ, start_response) |
|
22 | 23 | |
@@ -39,7 +40,8 b' class ProfilingMiddleware(object):' | |||
|
39 | 40 | if resp.strip().startswith('<'): |
|
40 | 41 | ## The profiling info is just appended to the response. |
|
41 | 42 | ## Browsers don't mind this. |
|
42 |
resp += '<pre style="text-align:left; |
|
|
43 | resp += ('<pre style="text-align:left; ' | |
|
44 | 'border-top: 4px dashed red; padding: 1em;">') | |
|
43 | 45 | resp += cgi.escape(out.getvalue(), True) |
|
44 | 46 | |
|
45 | 47 | output = StringIO() |
@@ -23,10 +23,12 b' from email.mime.text import MIMEText' | |||
|
23 | 23 | from email.utils import formatdate |
|
24 | 24 | from email import encoders |
|
25 | 25 | |
|
26 | ||
|
26 | 27 | class SmtpMailer(object): |
|
27 | 28 | """SMTP mailer class |
|
28 | 29 | |
|
29 |
mailer = SmtpMailer(mail_from, user, passwd, mail_server, |
|
|
30 | mailer = SmtpMailer(mail_from, user, passwd, mail_server, | |
|
31 | mail_port, ssl, tls) | |
|
30 | 32 | mailer.send(recipients, subject, body, attachment_files) |
|
31 | 33 | |
|
32 | 34 | :param recipients might be a list of string or single string |
@@ -70,7 +72,6 b' class SmtpMailer(object):' | |||
|
70 | 72 | if self.user and self.passwd: |
|
71 | 73 | smtp_serv.login(self.user, self.passwd) |
|
72 | 74 | |
|
73 | ||
|
74 | 75 | date_ = formatdate(localtime=True) |
|
75 | 76 | msg = MIMEMultipart() |
|
76 | 77 | msg['From'] = self.mail_from |
@@ -93,16 +94,15 b' class SmtpMailer(object):' | |||
|
93 | 94 | # sslerror is raised in tls connections on closing sometimes |
|
94 | 95 | pass |
|
95 | 96 | |
|
96 | ||
|
97 | ||
|
98 | 97 | def __atach_files(self, msg, attachment_files): |
|
99 | 98 | if isinstance(attachment_files, dict): |
|
100 | 99 | for f_name, msg_file in attachment_files.items(): |
|
101 | 100 | ctype, encoding = mimetypes.guess_type(f_name) |
|
102 |
logging.info("guessing file %s type based on %s" |
|
|
101 | logging.info("guessing file %s type based on %s", ctype, | |
|
102 | f_name) | |
|
103 | 103 | if ctype is None or encoding is not None: |
|
104 |
# No guess could be made, or the file is encoded |
|
|
105 | # use a generic bag-of-bits type. | |
|
104 | # No guess could be made, or the file is encoded | |
|
105 | # (compressed), so use a generic bag-of-bits type. | |
|
106 | 106 | ctype = 'application/octet-stream' |
|
107 | 107 | maintype, subtype = ctype.split('/', 1) |
|
108 | 108 | if maintype == 'text': |
@@ -5,12 +5,14 b" log = logging.getLogger('timerproxy')" | |||
|
5 | 5 | |
|
6 | 6 | BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE = xrange(30, 38) |
|
7 | 7 | |
|
8 | ||
|
8 | 9 | def color_sql(sql): |
|
9 | 10 | COLOR_SEQ = "\033[1;%dm" |
|
10 | 11 | COLOR_SQL = YELLOW |
|
11 | 12 | normal = '\x1b[0m' |
|
12 | 13 | return COLOR_SEQ % COLOR_SQL + sql + normal |
|
13 | 14 | |
|
15 | ||
|
14 | 16 | class TimerProxy(ConnectionProxy): |
|
15 | 17 | |
|
16 | 18 | def __init__(self): |
General Comments 0
You need to be logged in to leave comments.
Login now