diff options
Diffstat (limited to 'subcmds')
-rw-r--r-- | subcmds/forall.py | 29 | ||||
-rw-r--r-- | subcmds/gitc_delete.py | 4 | ||||
-rw-r--r-- | subcmds/init.py | 4 | ||||
-rw-r--r-- | subcmds/sync.py | 4 | ||||
-rw-r--r-- | subcmds/upload.py | 7 |
5 files changed, 21 insertions, 27 deletions
diff --git a/subcmds/forall.py b/subcmds/forall.py index 07ee8d58..2c12c55f 100644 --- a/subcmds/forall.py +++ b/subcmds/forall.py | |||
@@ -15,17 +15,16 @@ | |||
15 | 15 | ||
16 | from __future__ import print_function | 16 | from __future__ import print_function |
17 | import errno | 17 | import errno |
18 | import fcntl | ||
19 | import multiprocessing | 18 | import multiprocessing |
20 | import re | 19 | import re |
21 | import os | 20 | import os |
22 | import select | ||
23 | import signal | 21 | import signal |
24 | import sys | 22 | import sys |
25 | import subprocess | 23 | import subprocess |
26 | 24 | ||
27 | from color import Coloring | 25 | from color import Coloring |
28 | from command import Command, MirrorSafeCommand | 26 | from command import Command, MirrorSafeCommand |
27 | import platform_utils | ||
29 | 28 | ||
30 | _CAN_COLOR = [ | 29 | _CAN_COLOR = [ |
31 | 'branch', | 30 | 'branch', |
@@ -344,35 +343,25 @@ def DoWork(project, mirror, opt, cmd, shell, cnt, config): | |||
344 | if opt.project_header: | 343 | if opt.project_header: |
345 | out = ForallColoring(config) | 344 | out = ForallColoring(config) |
346 | out.redirect(sys.stdout) | 345 | out.redirect(sys.stdout) |
347 | class sfd(object): | ||
348 | def __init__(self, fd, dest): | ||
349 | self.fd = fd | ||
350 | self.dest = dest | ||
351 | def fileno(self): | ||
352 | return self.fd.fileno() | ||
353 | |||
354 | empty = True | 346 | empty = True |
355 | errbuf = '' | 347 | errbuf = '' |
356 | 348 | ||
357 | p.stdin.close() | 349 | p.stdin.close() |
358 | s_in = [sfd(p.stdout, sys.stdout), | 350 | s_in = platform_utils.FileDescriptorStreams.create() |
359 | sfd(p.stderr, sys.stderr)] | 351 | s_in.add(p.stdout, sys.stdout, 'stdout') |
360 | 352 | s_in.add(p.stderr, sys.stderr, 'stderr') | |
361 | for s in s_in: | ||
362 | flags = fcntl.fcntl(s.fd, fcntl.F_GETFL) | ||
363 | fcntl.fcntl(s.fd, fcntl.F_SETFL, flags | os.O_NONBLOCK) | ||
364 | 353 | ||
365 | while s_in: | 354 | while not s_in.is_done: |
366 | in_ready, _out_ready, _err_ready = select.select(s_in, [], []) | 355 | in_ready = s_in.select() |
367 | for s in in_ready: | 356 | for s in in_ready: |
368 | buf = s.fd.read(4096) | 357 | buf = s.read() |
369 | if not buf: | 358 | if not buf: |
370 | s.fd.close() | 359 | s.close() |
371 | s_in.remove(s) | 360 | s_in.remove(s) |
372 | continue | 361 | continue |
373 | 362 | ||
374 | if not opt.verbose: | 363 | if not opt.verbose: |
375 | if s.fd != p.stdout: | 364 | if s.std_name == 'stderr': |
376 | errbuf += buf | 365 | errbuf += buf |
377 | continue | 366 | continue |
378 | 367 | ||
diff --git a/subcmds/gitc_delete.py b/subcmds/gitc_delete.py index 19caac5a..54f62f46 100644 --- a/subcmds/gitc_delete.py +++ b/subcmds/gitc_delete.py | |||
@@ -14,10 +14,10 @@ | |||
14 | # limitations under the License. | 14 | # limitations under the License. |
15 | 15 | ||
16 | from __future__ import print_function | 16 | from __future__ import print_function |
17 | import shutil | ||
18 | import sys | 17 | import sys |
19 | 18 | ||
20 | from command import Command, GitcClientCommand | 19 | from command import Command, GitcClientCommand |
20 | import platform_utils | ||
21 | 21 | ||
22 | from pyversion import is_python3 | 22 | from pyversion import is_python3 |
23 | if not is_python3(): | 23 | if not is_python3(): |
@@ -50,4 +50,4 @@ and all locally downloaded sources. | |||
50 | if not response == 'yes': | 50 | if not response == 'yes': |
51 | print('Response was not "yes"\n Exiting...') | 51 | print('Response was not "yes"\n Exiting...') |
52 | sys.exit(1) | 52 | sys.exit(1) |
53 | shutil.rmtree(self.gitc_manifest.gitc_client_dir) | 53 | platform_utils.rmtree(self.gitc_manifest.gitc_client_dir) |
diff --git a/subcmds/init.py b/subcmds/init.py index 46cdd23a..eeddca06 100644 --- a/subcmds/init.py +++ b/subcmds/init.py | |||
@@ -17,7 +17,6 @@ from __future__ import print_function | |||
17 | import os | 17 | import os |
18 | import platform | 18 | import platform |
19 | import re | 19 | import re |
20 | import shutil | ||
21 | import sys | 20 | import sys |
22 | 21 | ||
23 | from pyversion import is_python3 | 22 | from pyversion import is_python3 |
@@ -35,6 +34,7 @@ from error import ManifestParseError | |||
35 | from project import SyncBuffer | 34 | from project import SyncBuffer |
36 | from git_config import GitConfig | 35 | from git_config import GitConfig |
37 | from git_command import git_require, MIN_GIT_VERSION | 36 | from git_command import git_require, MIN_GIT_VERSION |
37 | import platform_utils | ||
38 | 38 | ||
39 | class Init(InteractiveCommand, MirrorSafeCommand): | 39 | class Init(InteractiveCommand, MirrorSafeCommand): |
40 | common = True | 40 | common = True |
@@ -252,7 +252,7 @@ to update the working directory files. | |||
252 | # Better delete the manifest git dir if we created it; otherwise next | 252 | # Better delete the manifest git dir if we created it; otherwise next |
253 | # time (when user fixes problems) we won't go through the "is_new" logic. | 253 | # time (when user fixes problems) we won't go through the "is_new" logic. |
254 | if is_new: | 254 | if is_new: |
255 | shutil.rmtree(m.gitdir) | 255 | platform_utils.rmtree(m.gitdir) |
256 | sys.exit(1) | 256 | sys.exit(1) |
257 | 257 | ||
258 | if opt.manifest_branch: | 258 | if opt.manifest_branch: |
diff --git a/subcmds/sync.py b/subcmds/sync.py index 8de730bc..b88c596d 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py | |||
@@ -19,7 +19,6 @@ import netrc | |||
19 | from optparse import SUPPRESS_HELP | 19 | from optparse import SUPPRESS_HELP |
20 | import os | 20 | import os |
21 | import re | 21 | import re |
22 | import shutil | ||
23 | import socket | 22 | import socket |
24 | import subprocess | 23 | import subprocess |
25 | import sys | 24 | import sys |
@@ -73,6 +72,7 @@ from project import Project | |||
73 | from project import RemoteSpec | 72 | from project import RemoteSpec |
74 | from command import Command, MirrorSafeCommand | 73 | from command import Command, MirrorSafeCommand |
75 | from error import RepoChangedException, GitError, ManifestParseError | 74 | from error import RepoChangedException, GitError, ManifestParseError |
75 | import platform_utils | ||
76 | from project import SyncBuffer | 76 | from project import SyncBuffer |
77 | from progress import Progress | 77 | from progress import Progress |
78 | from wrapper import Wrapper | 78 | from wrapper import Wrapper |
@@ -475,7 +475,7 @@ later is required to fix a server side protocol bug. | |||
475 | # working git repository around. There shouldn't be any git projects here, | 475 | # working git repository around. There shouldn't be any git projects here, |
476 | # so rmtree works. | 476 | # so rmtree works. |
477 | try: | 477 | try: |
478 | shutil.rmtree(os.path.join(path, '.git')) | 478 | platform_utils.rmtree(os.path.join(path, '.git')) |
479 | except OSError: | 479 | except OSError: |
480 | print('Failed to remove %s' % os.path.join(path, '.git'), file=sys.stderr) | 480 | print('Failed to remove %s' % os.path.join(path, '.git'), file=sys.stderr) |
481 | print('error: Failed to delete obsolete path %s' % path, file=sys.stderr) | 481 | print('error: Failed to delete obsolete path %s' % path, file=sys.stderr) |
diff --git a/subcmds/upload.py b/subcmds/upload.py index 61b18bc2..60feff7a 100644 --- a/subcmds/upload.py +++ b/subcmds/upload.py | |||
@@ -181,6 +181,9 @@ Gerrit Code Review: http://code.google.com/p/gerrit/ | |||
181 | # Never run upload hooks, but upload anyway (AKA bypass hooks). | 181 | # Never run upload hooks, but upload anyway (AKA bypass hooks). |
182 | # - no-verify=True, verify=True: | 182 | # - no-verify=True, verify=True: |
183 | # Invalid | 183 | # Invalid |
184 | p.add_option('--no-cert-checks', | ||
185 | dest='validate_certs', action='store_false', default=True, | ||
186 | help='Disable verifying ssl certs (unsafe).') | ||
184 | p.add_option('--no-verify', | 187 | p.add_option('--no-verify', |
185 | dest='bypass_hooks', action='store_true', | 188 | dest='bypass_hooks', action='store_true', |
186 | help='Do not run the upload hook.') | 189 | help='Do not run the upload hook.') |
@@ -389,7 +392,9 @@ Gerrit Code Review: http://code.google.com/p/gerrit/ | |||
389 | draft=opt.draft, | 392 | draft=opt.draft, |
390 | private=opt.private, | 393 | private=opt.private, |
391 | wip=opt.wip, | 394 | wip=opt.wip, |
392 | dest_branch=destination) | 395 | dest_branch=destination, |
396 | validate_certs=opt.validate_certs) | ||
397 | |||
393 | branch.uploaded = True | 398 | branch.uploaded = True |
394 | except UploadError as e: | 399 | except UploadError as e: |
395 | branch.error = e | 400 | branch.error = e |