OLD | NEW |
1 # Copyright (c) 2010 Google Inc. All rights reserved. | 1 # Copyright (c) 2010 Google Inc. All rights reserved. |
2 # | 2 # |
3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
5 # met: | 5 # met: |
6 # | 6 # |
7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
(...skipping 21 matching lines...) Expand all Loading... |
32 import logging | 32 import logging |
33 import zipfile | 33 import zipfile |
34 | 34 |
35 from webkitpy.common.system.executive import ScriptError | 35 from webkitpy.common.system.executive import ScriptError |
36 | 36 |
37 | 37 |
38 _log = logging.getLogger(__name__) | 38 _log = logging.getLogger(__name__) |
39 | 39 |
40 | 40 |
41 class Workspace(object): | 41 class Workspace(object): |
| 42 |
42 def __init__(self, filesystem, executive): | 43 def __init__(self, filesystem, executive): |
43 self._filesystem = filesystem | 44 self._filesystem = filesystem |
44 self._executive = executive # FIXME: Remove if create_zip is moved to p
ython. | 45 self._executive = executive # FIXME: Remove if create_zip is moved to p
ython. |
45 | 46 |
46 def find_unused_filename(self, directory, name, extension, search_limit=100)
: | 47 def find_unused_filename(self, directory, name, extension, search_limit=100)
: |
47 for count in range(search_limit): | 48 for count in range(search_limit): |
48 if count: | 49 if count: |
49 target_name = "%s-%s.%s" % (name, count, extension) | 50 target_name = "%s-%s.%s" % (name, count, extension) |
50 else: | 51 else: |
51 target_name = "%s.%s" % (name, extension) | 52 target_name = "%s.%s" % (name, extension) |
(...skipping 12 matching lines...) Expand all Loading... |
64 # zip_file.write(os.path.relpath(path, source_path)) | 65 # zip_file.write(os.path.relpath(path, source_path)) |
65 # However, getting the paths, encoding and compression correct could be
non-trivial. | 66 # However, getting the paths, encoding and compression correct could be
non-trivial. |
66 # So, for now we depend on the environment having "zip" installed (likel
y fails on Win32) | 67 # So, for now we depend on the environment having "zip" installed (likel
y fails on Win32) |
67 try: | 68 try: |
68 self._executive.run_command(['zip', '-9', '-r', zip_path, '.'], cwd=
source_path) | 69 self._executive.run_command(['zip', '-9', '-r', zip_path, '.'], cwd=
source_path) |
69 except ScriptError, e: | 70 except ScriptError, e: |
70 _log.error("Workspace.create_zip failed in %s:\n%s" % (source_path,
e.message_with_output())) | 71 _log.error("Workspace.create_zip failed in %s:\n%s" % (source_path,
e.message_with_output())) |
71 return None | 72 return None |
72 | 73 |
73 return zip_class(zip_path) | 74 return zip_class(zip_path) |
OLD | NEW |