Show More
@@ -25,6 +25,8 b' Original author and date, and relevant c' | |||||
25 | :license: GPLv3, see LICENSE.md for more details. |
|
25 | :license: GPLv3, see LICENSE.md for more details. | |
26 | """ |
|
26 | """ | |
27 |
|
27 | |||
|
28 | from __future__ import print_function | |||
|
29 | ||||
28 | import argparse |
|
30 | import argparse | |
29 | import sys |
|
31 | import sys | |
30 |
|
32 | |||
@@ -104,7 +106,7 b' def main(argv=None):' | |||||
104 | sys.stderr.write('Error parsing arguments \n') |
|
106 | sys.stderr.write('Error parsing arguments \n') | |
105 | sys.exit() |
|
107 | sys.exit() | |
106 | if args.format == FORMAT_PRETTY: |
|
108 | if args.format == FORMAT_PRETTY: | |
107 |
print |
|
109 | print('Calling method %s => %s' % (method, apihost)) | |
108 |
|
110 | |||
109 | json_resp = api_call(apikey, apihost, method, **margs) |
|
111 | json_resp = api_call(apikey, apihost, method, **margs) | |
110 | error_prefix = '' |
|
112 | error_prefix = '' | |
@@ -114,11 +116,11 b' def main(argv=None):' | |||||
114 | else: |
|
116 | else: | |
115 | json_data = json_resp['result'] |
|
117 | json_data = json_resp['result'] | |
116 | if args.format == FORMAT_JSON: |
|
118 | if args.format == FORMAT_JSON: | |
117 |
print |
|
119 | print(json.dumps(json_data)) | |
118 | elif args.format == FORMAT_PRETTY: |
|
120 | elif args.format == FORMAT_PRETTY: | |
119 |
print |
|
121 | print('Server response \n%s%s' % ( | |
120 | error_prefix, json.dumps(json_data, indent=4, sort_keys=True) |
|
122 | error_prefix, json.dumps(json_data, indent=4, sort_keys=True) | |
121 | ) |
|
123 | )) | |
122 | return 0 |
|
124 | return 0 | |
123 |
|
125 | |||
124 |
|
126 |
@@ -19,6 +19,9 b' Original author and date, and relevant c' | |||||
19 | :copyright: (c) 2013 RhodeCode GmbH, and others. |
|
19 | :copyright: (c) 2013 RhodeCode GmbH, and others. | |
20 | :license: GPLv3, see LICENSE.md for more details. |
|
20 | :license: GPLv3, see LICENSE.md for more details. | |
21 | """ |
|
21 | """ | |
|
22 | ||||
|
23 | from __future__ import print_function | |||
|
24 | ||||
22 | import sys |
|
25 | import sys | |
23 |
|
26 | |||
24 | import kallithea.bin.kallithea_cli_base as cli_base |
|
27 | import kallithea.bin.kallithea_cli_base as cli_base | |
@@ -31,7 +34,7 b' def ishell():' | |||||
31 | try: |
|
34 | try: | |
32 | from IPython import embed |
|
35 | from IPython import embed | |
33 | except ImportError: |
|
36 | except ImportError: | |
34 |
print |
|
37 | print('Kallithea ishell requires the Python package IPython 4 or later') | |
35 | sys.exit(-1) |
|
38 | sys.exit(-1) | |
36 | from traitlets.config.loader import Config |
|
39 | from traitlets.config.loader import Config | |
37 | cfg = Config() |
|
40 | cfg = Config() |
@@ -25,6 +25,8 b' Original author and date, and relevant c' | |||||
25 | :license: GPLv3, see LICENSE.md for more details. |
|
25 | :license: GPLv3, see LICENSE.md for more details. | |
26 | """ |
|
26 | """ | |
27 |
|
27 | |||
|
28 | from __future__ import print_function | |||
|
29 | ||||
28 | import argparse |
|
30 | import argparse | |
29 | import fileinput |
|
31 | import fileinput | |
30 | import os |
|
32 | import os | |
@@ -144,11 +146,11 b' def _run(argv):' | |||||
144 |
|
146 | |||
145 | json_data = api_call(apikey, host, 'create_gist', **margs)['result'] |
|
147 | json_data = api_call(apikey, host, 'create_gist', **margs)['result'] | |
146 | if args.format == FORMAT_JSON: |
|
148 | if args.format == FORMAT_JSON: | |
147 |
print |
|
149 | print(json.dumps(json_data)) | |
148 | elif args.format == FORMAT_PRETTY: |
|
150 | elif args.format == FORMAT_PRETTY: | |
149 |
print |
|
151 | print(json_data) | |
150 |
print |
|
152 | print('Created %s gist %s' % (json_data['gist']['type'], | |
151 | json_data['gist']['url']) |
|
153 | json_data['gist']['url'])) | |
152 | return 0 |
|
154 | return 0 | |
153 |
|
155 | |||
154 |
|
156 | |||
@@ -164,7 +166,7 b' def main(argv=None):' | |||||
164 | try: |
|
166 | try: | |
165 | return _run(argv) |
|
167 | return _run(argv) | |
166 | except Exception as e: |
|
168 | except Exception as e: | |
167 |
print |
|
169 | print(e) | |
168 | return 1 |
|
170 | return 1 | |
169 |
|
171 | |||
170 |
|
172 |
@@ -25,6 +25,8 b' Original author and date, and relevant c' | |||||
25 | :license: GPLv3, see LICENSE.md for more details. |
|
25 | :license: GPLv3, see LICENSE.md for more details. | |
26 | """ |
|
26 | """ | |
27 |
|
27 | |||
|
28 | from __future__ import print_function | |||
|
29 | ||||
28 | import urllib2 |
|
30 | import urllib2 | |
29 | import uuid |
|
31 | import uuid | |
30 | from ConfigParser import ConfigParser |
|
32 | from ConfigParser import ConfigParser | |
@@ -242,7 +244,7 b' class LdapSync(object):' | |||||
242 |
|
244 | |||
243 | if __name__ == '__main__': |
|
245 | if __name__ == '__main__': | |
244 | sync = LdapSync() |
|
246 | sync = LdapSync() | |
245 |
print |
|
247 | print(sync.update_groups_from_ldap()) | |
246 |
|
248 | |||
247 | for gr in sync.ldap_client.get_groups(): |
|
249 | for gr in sync.ldap_client.get_groups(): | |
248 | # TODO: exception when user does not exist during add membership... |
|
250 | # TODO: exception when user does not exist during add membership... |
@@ -26,6 +26,8 b' Original author and date, and relevant c' | |||||
26 | :license: GPLv3, see LICENSE.md for more details. |
|
26 | :license: GPLv3, see LICENSE.md for more details. | |
27 | """ |
|
27 | """ | |
28 |
|
28 | |||
|
29 | from __future__ import print_function | |||
|
30 | ||||
29 | import logging |
|
31 | import logging | |
30 | import os |
|
32 | import os | |
31 | import sys |
|
33 | import sys | |
@@ -86,7 +88,7 b' class DbManage(object):' | |||||
86 | else: |
|
88 | else: | |
87 | destroy = self._ask_ok('Are you sure to destroy old database ? [y/n]') |
|
89 | destroy = self._ask_ok('Are you sure to destroy old database ? [y/n]') | |
88 | if not destroy: |
|
90 | if not destroy: | |
89 |
print |
|
91 | print('Nothing done.') | |
90 | sys.exit(0) |
|
92 | sys.exit(0) | |
91 | if destroy: |
|
93 | if destroy: | |
92 | # drop and re-create old schemas |
|
94 | # drop and re-create old schemas |
@@ -12,6 +12,8 b'' | |||||
12 | # You should have received a copy of the GNU General Public License |
|
12 | # You should have received a copy of the GNU General Public License | |
13 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
13 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
14 |
|
14 | |||
|
15 | from __future__ import print_function | |||
|
16 | ||||
15 | import errno |
|
17 | import errno | |
16 | import os |
|
18 | import os | |
17 | from multiprocessing.util import Finalize |
|
19 | from multiprocessing.util import Finalize | |
@@ -50,7 +52,7 b' class DaemonLock(object):' | |||||
50 | def _on_finalize(lock, debug): |
|
52 | def _on_finalize(lock, debug): | |
51 | if lock.held: |
|
53 | if lock.held: | |
52 | if debug: |
|
54 | if debug: | |
53 |
print |
|
55 | print('lock held finalizing and running lock.release()') | |
54 | lock.release() |
|
56 | lock.release() | |
55 |
|
57 | |||
56 | def lock(self): |
|
58 | def lock(self): | |
@@ -60,7 +62,7 b' class DaemonLock(object):' | |||||
60 | """ |
|
62 | """ | |
61 | lockname = str(os.getpid()) |
|
63 | lockname = str(os.getpid()) | |
62 | if self.debug: |
|
64 | if self.debug: | |
63 |
print |
|
65 | print('running lock') | |
64 | self.trylock() |
|
66 | self.trylock() | |
65 | self.makelock(lockname, self.pidfile) |
|
67 | self.makelock(lockname, self.pidfile) | |
66 | return True |
|
68 | return True | |
@@ -68,7 +70,7 b' class DaemonLock(object):' | |||||
68 | def trylock(self): |
|
70 | def trylock(self): | |
69 | running_pid = False |
|
71 | running_pid = False | |
70 | if self.debug: |
|
72 | if self.debug: | |
71 |
print |
|
73 | print('checking for already running process') | |
72 | try: |
|
74 | try: | |
73 | with open(self.pidfile, 'r') as f: |
|
75 | with open(self.pidfile, 'r') as f: | |
74 | try: |
|
76 | try: | |
@@ -77,8 +79,8 b' class DaemonLock(object):' | |||||
77 | running_pid = -1 |
|
79 | running_pid = -1 | |
78 |
|
80 | |||
79 | if self.debug: |
|
81 | if self.debug: | |
80 |
print |
|
82 | print('lock file present running_pid: %s, ' | |
81 |
|
|
83 | 'checking for execution' % (running_pid,)) | |
82 | # Now we check the PID from lock file matches to the current |
|
84 | # Now we check the PID from lock file matches to the current | |
83 | # process PID |
|
85 | # process PID | |
84 | if running_pid: |
|
86 | if running_pid: | |
@@ -88,13 +90,13 b' class DaemonLock(object):' | |||||
88 | if exc.errno in (errno.ESRCH, errno.EPERM): |
|
90 | if exc.errno in (errno.ESRCH, errno.EPERM): | |
89 | print ("Lock File is there but" |
|
91 | print ("Lock File is there but" | |
90 | " the program is not running") |
|
92 | " the program is not running") | |
91 |
print |
|
93 | print("Removing lock file for the: %s" % running_pid) | |
92 | self.release() |
|
94 | self.release() | |
93 | else: |
|
95 | else: | |
94 | raise |
|
96 | raise | |
95 | else: |
|
97 | else: | |
96 |
print |
|
98 | print("You already have an instance of the program running") | |
97 |
print |
|
99 | print("It is running as process %s" % running_pid) | |
98 | raise LockHeld() |
|
100 | raise LockHeld() | |
99 |
|
101 | |||
100 | except IOError as e: |
|
102 | except IOError as e: | |
@@ -105,21 +107,21 b' class DaemonLock(object):' | |||||
105 | """releases the pid by removing the pidfile |
|
107 | """releases the pid by removing the pidfile | |
106 | """ |
|
108 | """ | |
107 | if self.debug: |
|
109 | if self.debug: | |
108 |
print |
|
110 | print('trying to release the pidlock') | |
109 |
|
111 | |||
110 | if self.callbackfn: |
|
112 | if self.callbackfn: | |
111 | #execute callback function on release |
|
113 | #execute callback function on release | |
112 | if self.debug: |
|
114 | if self.debug: | |
113 |
print |
|
115 | print('executing callback function %s' % self.callbackfn) | |
114 | self.callbackfn() |
|
116 | self.callbackfn() | |
115 | try: |
|
117 | try: | |
116 | if self.debug: |
|
118 | if self.debug: | |
117 |
print |
|
119 | print('removing pidfile %s' % self.pidfile) | |
118 | os.remove(self.pidfile) |
|
120 | os.remove(self.pidfile) | |
119 | self.held = False |
|
121 | self.held = False | |
120 | except OSError as e: |
|
122 | except OSError as e: | |
121 | if self.debug: |
|
123 | if self.debug: | |
122 |
print |
|
124 | print('removing pidfile failed %s' % e) | |
123 | pass |
|
125 | pass | |
124 |
|
126 | |||
125 | def makelock(self, lockname, pidfile): |
|
127 | def makelock(self, lockname, pidfile): | |
@@ -130,7 +132,7 b' class DaemonLock(object):' | |||||
130 | :param pidfile: the file to write the pid in |
|
132 | :param pidfile: the file to write the pid in | |
131 | """ |
|
133 | """ | |
132 | if self.debug: |
|
134 | if self.debug: | |
133 |
print |
|
135 | print('creating a file %s and pid: %s' % (pidfile, lockname)) | |
134 |
|
136 | |||
135 | dir_, file_ = os.path.split(pidfile) |
|
137 | dir_, file_ = os.path.split(pidfile) | |
136 | if not os.path.isdir(dir_): |
|
138 | if not os.path.isdir(dir_): |
@@ -27,6 +27,7 b' Original author and date, and relevant c' | |||||
27 | :license: GPLv3, see LICENSE.md for more details. |
|
27 | :license: GPLv3, see LICENSE.md for more details. | |
28 | """ |
|
28 | """ | |
29 |
|
29 | |||
|
30 | from __future__ import print_function | |||
30 |
|
31 | |||
31 | import binascii |
|
32 | import binascii | |
32 | import datetime |
|
33 | import datetime | |
@@ -697,4 +698,4 b' def ask_ok(prompt, retries=4, complaint=' | |||||
697 | retries = retries - 1 |
|
698 | retries = retries - 1 | |
698 | if retries < 0: |
|
699 | if retries < 0: | |
699 | raise IOError |
|
700 | raise IOError | |
700 |
print |
|
701 | print(complaint) |
@@ -1,4 +1,7 b'' | |||||
1 | # encoding: UTF-8 |
|
1 | # encoding: UTF-8 | |
|
2 | ||||
|
3 | from __future__ import print_function | |||
|
4 | ||||
2 | import datetime |
|
5 | import datetime | |
3 | import string |
|
6 | import string | |
4 | import sys |
|
7 | import sys | |
@@ -354,54 +357,54 b' class BarOnlyColoredProgressBar(ColoredP' | |||||
354 | def main(): |
|
357 | def main(): | |
355 | import time |
|
358 | import time | |
356 |
|
359 | |||
357 |
print |
|
360 | print("Standard progress bar...") | |
358 | bar = ProgressBar(30) |
|
361 | bar = ProgressBar(30) | |
359 | for x in xrange(1, 31): |
|
362 | for x in xrange(1, 31): | |
360 | bar.render(x) |
|
363 | bar.render(x) | |
361 | time.sleep(0.02) |
|
364 | time.sleep(0.02) | |
362 | bar.stream.write('\n') |
|
365 | bar.stream.write('\n') | |
363 |
|
366 | print() | ||
364 |
|
367 | |||
365 |
print |
|
368 | print("Empty bar...") | |
366 | bar = ProgressBar(50) |
|
369 | bar = ProgressBar(50) | |
367 | bar.render(0) |
|
370 | bar.render(0) | |
368 |
|
371 | print() | ||
369 |
|
372 | print() | ||
370 |
|
373 | |||
371 |
print |
|
374 | print("Colored bar...") | |
372 | bar = ColoredProgressBar(20) |
|
375 | bar = ColoredProgressBar(20) | |
373 | for x in bar: |
|
376 | for x in bar: | |
374 | time.sleep(0.01) |
|
377 | time.sleep(0.01) | |
375 |
|
378 | print() | ||
376 |
|
379 | |||
377 |
print |
|
380 | print("Animated char bar...") | |
378 | bar = AnimatedProgressBar(20) |
|
381 | bar = AnimatedProgressBar(20) | |
379 | for x in bar: |
|
382 | for x in bar: | |
380 | time.sleep(0.01) |
|
383 | time.sleep(0.01) | |
381 |
|
384 | print() | ||
382 |
|
385 | |||
383 |
print |
|
386 | print("Animated + colored char bar...") | |
384 | bar = AnimatedColoredProgressBar(20) |
|
387 | bar = AnimatedColoredProgressBar(20) | |
385 | for x in bar: |
|
388 | for x in bar: | |
386 | time.sleep(0.01) |
|
389 | time.sleep(0.01) | |
387 |
|
390 | print() | ||
388 |
|
391 | |||
389 |
print |
|
392 | print("Bar only ...") | |
390 | bar = BarOnlyProgressBar(20) |
|
393 | bar = BarOnlyProgressBar(20) | |
391 | for x in bar: |
|
394 | for x in bar: | |
392 | time.sleep(0.01) |
|
395 | time.sleep(0.01) | |
393 |
|
396 | print() | ||
394 |
|
397 | |||
395 |
print |
|
398 | print("Colored, longer bar-only, eta, total time ...") | |
396 | bar = BarOnlyColoredProgressBar(40) |
|
399 | bar = BarOnlyColoredProgressBar(40) | |
397 | bar.width = 60 |
|
400 | bar.width = 60 | |
398 | bar.elements += ['time', 'eta'] |
|
401 | bar.elements += ['time', 'eta'] | |
399 | for x in bar: |
|
402 | for x in bar: | |
400 | time.sleep(0.01) |
|
403 | time.sleep(0.01) | |
401 |
|
404 | print() | ||
402 |
|
405 | print() | ||
403 |
|
406 | |||
404 |
print |
|
407 | print("File transfer bar, breaks after 2 seconds ...") | |
405 | total_bytes = 1024 * 1024 * 2 |
|
408 | total_bytes = 1024 * 1024 * 2 | |
406 | bar = ProgressBar(total_bytes) |
|
409 | bar = ProgressBar(total_bytes) | |
407 | bar.width = 50 |
|
410 | bar.width = 50 | |
@@ -413,8 +416,8 b' def main():' | |||||
413 | now = datetime.datetime.now() |
|
416 | now = datetime.datetime.now() | |
414 | if now - bar.started >= datetime.timedelta(seconds=2): |
|
417 | if now - bar.started >= datetime.timedelta(seconds=2): | |
415 | break |
|
418 | break | |
416 |
|
419 | print() | ||
417 |
|
420 | print() | ||
418 |
|
421 | |||
419 |
|
422 | |||
420 | if __name__ == '__main__': |
|
423 | if __name__ == '__main__': |
@@ -25,6 +25,8 b' Original author and date, and relevant c' | |||||
25 |
|
25 | |||
26 | """ |
|
26 | """ | |
27 |
|
27 | |||
|
28 | from __future__ import print_function | |||
|
29 | ||||
28 | import json |
|
30 | import json | |
29 | import os |
|
31 | import os | |
30 | import re |
|
32 | import re | |
@@ -144,7 +146,7 b' class Command(object):' | |||||
144 | command = ' '.join(args) |
|
146 | command = ' '.join(args) | |
145 | ignoreReturnCode = environ.pop('ignoreReturnCode', False) |
|
147 | ignoreReturnCode = environ.pop('ignoreReturnCode', False) | |
146 | if DEBUG: |
|
148 | if DEBUG: | |
147 |
print |
|
149 | print('*** CMD %s ***' % command) | |
148 | testenv = dict(os.environ) |
|
150 | testenv = dict(os.environ) | |
149 | testenv['LANG'] = 'en_US.UTF-8' |
|
151 | testenv['LANG'] = 'en_US.UTF-8' | |
150 | testenv['LANGUAGE'] = 'en_US:en' |
|
152 | testenv['LANGUAGE'] = 'en_US:en' | |
@@ -155,9 +157,9 b' class Command(object):' | |||||
155 | stdout, stderr = p.communicate() |
|
157 | stdout, stderr = p.communicate() | |
156 | if DEBUG: |
|
158 | if DEBUG: | |
157 | if stdout: |
|
159 | if stdout: | |
158 |
print |
|
160 | print('stdout:', stdout) | |
159 | if stderr: |
|
161 | if stderr: | |
160 |
print |
|
162 | print('stderr:', stderr) | |
161 | if not ignoreReturnCode: |
|
163 | if not ignoreReturnCode: | |
162 | assert p.returncode == 0 |
|
164 | assert p.returncode == 0 | |
163 | return stdout, stderr |
|
165 | return stdout, stderr |
@@ -26,6 +26,8 b' Original author and date, and relevant c' | |||||
26 |
|
26 | |||
27 | """ |
|
27 | """ | |
28 |
|
28 | |||
|
29 | from __future__ import print_function | |||
|
30 | ||||
29 | import logging |
|
31 | import logging | |
30 | import os |
|
32 | import os | |
31 | import shutil |
|
33 | import shutil | |
@@ -72,11 +74,11 b' class Command(object):' | |||||
72 | command = cmd + ' ' + ' '.join(args) |
|
74 | command = cmd + ' ' + ' '.join(args) | |
73 | log.debug('Executing %s', command) |
|
75 | log.debug('Executing %s', command) | |
74 | if DEBUG: |
|
76 | if DEBUG: | |
75 |
print |
|
77 | print(command) | |
76 | p = Popen(command, shell=True, stdout=PIPE, stderr=PIPE, cwd=self.cwd) |
|
78 | p = Popen(command, shell=True, stdout=PIPE, stderr=PIPE, cwd=self.cwd) | |
77 | stdout, stderr = p.communicate() |
|
79 | stdout, stderr = p.communicate() | |
78 | if DEBUG: |
|
80 | if DEBUG: | |
79 |
print |
|
81 | print(stdout, stderr) | |
80 | return stdout, stderr |
|
82 | return stdout, stderr | |
81 |
|
83 | |||
82 |
|
84 | |||
@@ -88,20 +90,20 b' def get_session():' | |||||
88 |
|
90 | |||
89 |
|
91 | |||
90 | def create_test_user(force=True): |
|
92 | def create_test_user(force=True): | |
91 |
print |
|
93 | print('creating test user') | |
92 | sa = get_session() |
|
94 | sa = get_session() | |
93 |
|
95 | |||
94 | user = sa.query(User).filter(User.username == USER).scalar() |
|
96 | user = sa.query(User).filter(User.username == USER).scalar() | |
95 |
|
97 | |||
96 | if force and user is not None: |
|
98 | if force and user is not None: | |
97 |
print |
|
99 | print('removing current user') | |
98 | for repo in sa.query(Repository).filter(Repository.user == user).all(): |
|
100 | for repo in sa.query(Repository).filter(Repository.user == user).all(): | |
99 | sa.delete(repo) |
|
101 | sa.delete(repo) | |
100 | sa.delete(user) |
|
102 | sa.delete(user) | |
101 | sa.commit() |
|
103 | sa.commit() | |
102 |
|
104 | |||
103 | if user is None or force: |
|
105 | if user is None or force: | |
104 |
print |
|
106 | print('creating new one') | |
105 | new_usr = User() |
|
107 | new_usr = User() | |
106 | new_usr.username = USER |
|
108 | new_usr.username = USER | |
107 | new_usr.password = get_crypt_password(PASS) |
|
109 | new_usr.password = get_crypt_password(PASS) | |
@@ -113,11 +115,11 b' def create_test_user(force=True):' | |||||
113 | sa.add(new_usr) |
|
115 | sa.add(new_usr) | |
114 | sa.commit() |
|
116 | sa.commit() | |
115 |
|
117 | |||
116 |
print |
|
118 | print('done') | |
117 |
|
119 | |||
118 |
|
120 | |||
119 | def create_test_repo(force=True): |
|
121 | def create_test_repo(force=True): | |
120 |
print |
|
122 | print('creating test repo') | |
121 | from kallithea.model.repo import RepoModel |
|
123 | from kallithea.model.repo import RepoModel | |
122 | sa = get_session() |
|
124 | sa = get_session() | |
123 |
|
125 | |||
@@ -128,7 +130,7 b' def create_test_repo(force=True):' | |||||
128 | repo = sa.query(Repository).filter(Repository.repo_name == HG_REPO).scalar() |
|
130 | repo = sa.query(Repository).filter(Repository.repo_name == HG_REPO).scalar() | |
129 |
|
131 | |||
130 | if repo is None: |
|
132 | if repo is None: | |
131 |
print |
|
133 | print('repo not found creating') | |
132 |
|
134 | |||
133 | form_data = {'repo_name': HG_REPO, |
|
135 | form_data = {'repo_name': HG_REPO, | |
134 | 'repo_type': 'hg', |
|
136 | 'repo_type': 'hg', | |
@@ -138,7 +140,7 b' def create_test_repo(force=True):' | |||||
138 | rm.base_path = '/home/hg' |
|
140 | rm.base_path = '/home/hg' | |
139 | rm.create(form_data, user) |
|
141 | rm.create(form_data, user) | |
140 |
|
142 | |||
141 |
print |
|
143 | print('done') | |
142 |
|
144 | |||
143 |
|
145 | |||
144 | def set_anonymous_access(enable=True): |
|
146 | def set_anonymous_access(enable=True): | |
@@ -208,9 +210,9 b" if __name__ == '__main__':" | |||||
208 | backend=backend) |
|
210 | backend=backend) | |
209 | s = time.time() |
|
211 | s = time.time() | |
210 | for i in range(1, int(sys.argv[2]) + 1): |
|
212 | for i in range(1, int(sys.argv[2]) + 1): | |
211 |
print |
|
213 | print('take', i) | |
212 | test_clone_with_credentials(repo=sys.argv[1], method=METHOD, |
|
214 | test_clone_with_credentials(repo=sys.argv[1], method=METHOD, | |
213 | backend=backend) |
|
215 | backend=backend) | |
214 |
print |
|
216 | print('time taken %.3f' % (time.time() - s)) | |
215 | except Exception as e: |
|
217 | except Exception as e: | |
216 | sys.exit('stop on %s' % e) |
|
218 | sys.exit('stop on %s' % e) |
@@ -30,6 +30,7 b' Original author and date, and relevant c' | |||||
30 | :license: GPLv3, see LICENSE.md for more details. |
|
30 | :license: GPLv3, see LICENSE.md for more details. | |
31 | """ |
|
31 | """ | |
32 |
|
32 | |||
|
33 | from __future__ import print_function | |||
33 |
|
34 | |||
34 | import cookielib |
|
35 | import cookielib | |
35 | import os |
|
36 | import os | |
@@ -61,7 +62,7 b' if len(sys.argv) == 2:' | |||||
61 | if not BASE_URI.endswith('/'): |
|
62 | if not BASE_URI.endswith('/'): | |
62 | BASE_URI += '/' |
|
63 | BASE_URI += '/' | |
63 |
|
64 | |||
64 |
print |
|
65 | print('Crawling @ %s' % BASE_URI) | |
65 | BASE_URI += '%s' |
|
66 | BASE_URI += '%s' | |
66 | PROJECT_PATH = os.path.join('/', 'home', 'username', 'repos') |
|
67 | PROJECT_PATH = os.path.join('/', 'home', 'username', 'repos') | |
67 | PROJECTS = [ |
|
68 | PROJECTS = [ | |
@@ -109,16 +110,16 b' def test_changelog_walk(proj, pages=100)' | |||||
109 | size = len(f.read()) |
|
110 | size = len(f.read()) | |
110 | e = time.time() - s |
|
111 | e = time.time() - s | |
111 | total_time += e |
|
112 | total_time += e | |
112 |
print |
|
113 | print('visited %s size:%s req:%s ms' % (full_uri, size, e)) | |
113 |
|
114 | |||
114 |
print |
|
115 | print('total_time', total_time) | |
115 |
print |
|
116 | print('average on req', total_time / float(pages)) | |
116 |
|
117 | |||
117 |
|
118 | |||
118 | def test_changeset_walk(proj, limit=None): |
|
119 | def test_changeset_walk(proj, limit=None): | |
119 | repo, proj = _get_repo(proj) |
|
120 | repo, proj = _get_repo(proj) | |
120 |
|
121 | |||
121 |
print |
|
122 | print('processing', os.path.join(PROJECT_PATH, proj)) | |
122 | total_time = 0 |
|
123 | total_time = 0 | |
123 |
|
124 | |||
124 | cnt = 0 |
|
125 | cnt = 0 | |
@@ -129,22 +130,22 b' def test_changeset_walk(proj, limit=None' | |||||
129 | break |
|
130 | break | |
130 |
|
131 | |||
131 | full_uri = (BASE_URI % raw_cs) |
|
132 | full_uri = (BASE_URI % raw_cs) | |
132 |
print |
|
133 | print('%s visiting %s\%s' % (cnt, full_uri, i)) | |
133 | s = time.time() |
|
134 | s = time.time() | |
134 | f = o.open(full_uri) |
|
135 | f = o.open(full_uri) | |
135 | size = len(f.read()) |
|
136 | size = len(f.read()) | |
136 | e = time.time() - s |
|
137 | e = time.time() - s | |
137 | total_time += e |
|
138 | total_time += e | |
138 |
print |
|
139 | print('%s visited %s\%s size:%s req:%s ms' % (cnt, full_uri, i, size, e)) | |
139 |
|
140 | |||
140 |
print |
|
141 | print('total_time', total_time) | |
141 |
print |
|
142 | print('average on req', total_time / float(cnt)) | |
142 |
|
143 | |||
143 |
|
144 | |||
144 | def test_files_walk(proj, limit=100): |
|
145 | def test_files_walk(proj, limit=100): | |
145 | repo, proj = _get_repo(proj) |
|
146 | repo, proj = _get_repo(proj) | |
146 |
|
147 | |||
147 |
print |
|
148 | print('processing', os.path.join(PROJECT_PATH, proj)) | |
148 | total_time = 0 |
|
149 | total_time = 0 | |
149 |
|
150 | |||
150 | paths_ = OrderedSet(['']) |
|
151 | paths_ = OrderedSet(['']) | |
@@ -171,22 +172,22 b' def test_files_walk(proj, limit=100):' | |||||
171 |
|
172 | |||
172 | file_path = '/'.join((proj, 'files', 'tip', f)) |
|
173 | file_path = '/'.join((proj, 'files', 'tip', f)) | |
173 | full_uri = (BASE_URI % file_path) |
|
174 | full_uri = (BASE_URI % file_path) | |
174 |
print |
|
175 | print('%s visiting %s' % (cnt, full_uri)) | |
175 | s = time.time() |
|
176 | s = time.time() | |
176 | f = o.open(full_uri) |
|
177 | f = o.open(full_uri) | |
177 | size = len(f.read()) |
|
178 | size = len(f.read()) | |
178 | e = time.time() - s |
|
179 | e = time.time() - s | |
179 | total_time += e |
|
180 | total_time += e | |
180 |
print |
|
181 | print('%s visited OK size:%s req:%s ms' % (cnt, size, e)) | |
181 |
|
182 | |||
182 |
print |
|
183 | print('total_time', total_time) | |
183 |
print |
|
184 | print('average on req', total_time / float(cnt)) | |
184 |
|
185 | |||
185 | if __name__ == '__main__': |
|
186 | if __name__ == '__main__': | |
186 | for path in PROJECTS: |
|
187 | for path in PROJECTS: | |
187 | repo = vcs.get_repo(os.path.join(PROJECT_PATH, path)) |
|
188 | repo = vcs.get_repo(os.path.join(PROJECT_PATH, path)) | |
188 | for i in range(PASES): |
|
189 | for i in range(PASES): | |
189 |
print |
|
190 | print('PASS %s/%s' % (i, PASES)) | |
190 | test_changelog_walk(repo, pages=80) |
|
191 | test_changelog_walk(repo, pages=80) | |
191 | test_changeset_walk(repo, limit=100) |
|
192 | test_changeset_walk(repo, limit=100) | |
192 | test_files_walk(repo, limit=100) |
|
193 | test_files_walk(repo, limit=100) |
@@ -4,6 +4,8 b'' | |||||
4 | Consistent formatting of rst section titles |
|
4 | Consistent formatting of rst section titles | |
5 | """ |
|
5 | """ | |
6 |
|
6 | |||
|
7 | from __future__ import print_function | |||
|
8 | ||||
7 | import re |
|
9 | import re | |
8 | import subprocess |
|
10 | import subprocess | |
9 |
|
11 | |||
@@ -33,7 +35,7 b" headermatch = re.compile(r'''\\n*(.+)\\n([" | |||||
33 | def main(): |
|
35 | def main(): | |
34 | filenames = subprocess.check_output(['hg', 'loc', 'set:**.rst+kallithea/i18n/how_to']).splitlines() |
|
36 | filenames = subprocess.check_output(['hg', 'loc', 'set:**.rst+kallithea/i18n/how_to']).splitlines() | |
35 | for fn in filenames: |
|
37 | for fn in filenames: | |
36 |
print |
|
38 | print('processing %s' % fn) | |
37 | s = open(fn).read() |
|
39 | s = open(fn).read() | |
38 |
|
40 | |||
39 | # find levels and their styles |
|
41 | # find levels and their styles | |
@@ -44,11 +46,11 b' def main():' | |||||
44 | if style in styles: |
|
46 | if style in styles: | |
45 | stylepos = styles.index(style) |
|
47 | stylepos = styles.index(style) | |
46 | if stylepos > lastpos + 1: |
|
48 | if stylepos > lastpos + 1: | |
47 |
print |
|
49 | print('bad style %r with level %s - was at %s' % (style, stylepos, lastpos)) | |
48 | else: |
|
50 | else: | |
49 | stylepos = len(styles) |
|
51 | stylepos = len(styles) | |
50 | if stylepos > lastpos + 1: |
|
52 | if stylepos > lastpos + 1: | |
51 |
print |
|
53 | print('bad new style %r - expected %r' % (style, styles[lastpos + 1])) | |
52 | else: |
|
54 | else: | |
53 | styles.append(style) |
|
55 | styles.append(style) | |
54 | lastpos = stylepos |
|
56 | lastpos = stylepos | |
@@ -75,7 +77,7 b' def main():' | |||||
75 |
|
77 | |||
76 | open(fn, 'w').write(s) |
|
78 | open(fn, 'w').write(s) | |
77 |
|
79 | |||
78 |
print |
|
80 | print(subprocess.check_output(['hg', 'diff'] + filenames)) | |
79 |
|
81 | |||
80 | if __name__ == '__main__': |
|
82 | if __name__ == '__main__': | |
81 | main() |
|
83 | main() |
@@ -3,6 +3,8 b'' | |||||
3 | Based on kallithea/lib/paster_commands/template.ini.mako, generate development.ini |
|
3 | Based on kallithea/lib/paster_commands/template.ini.mako, generate development.ini | |
4 | """ |
|
4 | """ | |
5 |
|
5 | |||
|
6 | from __future__ import print_function | |||
|
7 | ||||
6 | import re |
|
8 | import re | |
7 |
|
9 | |||
8 | from kallithea.lib import inifile |
|
10 | from kallithea.lib import inifile | |
@@ -52,17 +54,17 b' ini_files = [' | |||||
52 | def main(): |
|
54 | def main(): | |
53 | # make sure all mako lines starting with '#' (the '##' comments) are marked up as <text> |
|
55 | # make sure all mako lines starting with '#' (the '##' comments) are marked up as <text> | |
54 | makofile = inifile.template_file |
|
56 | makofile = inifile.template_file | |
55 |
print |
|
57 | print('reading:', makofile) | |
56 | mako_org = open(makofile).read() |
|
58 | mako_org = open(makofile).read() | |
57 | mako_no_text_markup = re.sub(r'</?%text>', '', mako_org) |
|
59 | mako_no_text_markup = re.sub(r'</?%text>', '', mako_org) | |
58 | mako_marked_up = re.sub(r'\n(##.*)', r'\n<%text>\1</%text>', mako_no_text_markup, flags=re.MULTILINE) |
|
60 | mako_marked_up = re.sub(r'\n(##.*)', r'\n<%text>\1</%text>', mako_no_text_markup, flags=re.MULTILINE) | |
59 | if mako_marked_up != mako_org: |
|
61 | if mako_marked_up != mako_org: | |
60 |
print |
|
62 | print('writing:', makofile) | |
61 | open(makofile, 'w').write(mako_marked_up) |
|
63 | open(makofile, 'w').write(mako_marked_up) | |
62 |
|
64 | |||
63 | # create ini files |
|
65 | # create ini files | |
64 | for fn, settings in ini_files: |
|
66 | for fn, settings in ini_files: | |
65 |
print |
|
67 | print('updating:', fn) | |
66 | inifile.create(fn, None, settings) |
|
68 | inifile.create(fn, None, settings) | |
67 |
|
69 | |||
68 |
|
70 |
@@ -1,5 +1,7 b'' | |||||
1 | #!/usr/bin/env python2 |
|
1 | #!/usr/bin/env python2 | |
2 |
|
2 | |||
|
3 | from __future__ import print_function | |||
|
4 | ||||
3 | import re |
|
5 | import re | |
4 | import sys |
|
6 | import sys | |
5 |
|
7 | |||
@@ -38,9 +40,9 b' def rewrite(f):' | |||||
38 |
|
40 | |||
39 | if __name__ == '__main__': |
|
41 | if __name__ == '__main__': | |
40 | if len(sys.argv) < 2: |
|
42 | if len(sys.argv) < 2: | |
41 |
print |
|
43 | print('Cleanup of superfluous % formatting of log statements.') | |
42 |
print |
|
44 | print('Usage:') | |
43 |
print |
|
45 | print(''' hg revert `hg loc '*.py'|grep -v logformat.py` && scripts/logformat.py `hg loc '*.py'` && hg diff''') | |
44 | raise SystemExit(1) |
|
46 | raise SystemExit(1) | |
45 |
|
47 | |||
46 | for f in sys.argv[1:]: |
|
48 | for f in sys.argv[1:]: |
General Comments 0
You need to be logged in to leave comments.
Login now