OLD | NEW |
1 """ | 1 """ |
2 This module defines the BasePackageManager Class which provides an | 2 This module defines the BasePackageManager Class which provides an |
3 implementation of the packaging system API providing methods to fetch, | 3 implementation of the packaging system API providing methods to fetch, |
4 upload and remove packages. Site specific extensions to any of these methods | 4 upload and remove packages. Site specific extensions to any of these methods |
5 should inherit this class. | 5 should inherit this class. |
6 """ | 6 """ |
7 | 7 |
8 import re, os, sys, traceback, subprocess, shutil, time, traceback, urlparse | 8 import re, os, sys, traceback, subprocess, shutil, time, traceback, urlparse |
9 import fcntl, logging | 9 import fcntl, logging |
10 from autotest_lib.client.common_lib import error, utils, global_config | 10 from autotest_lib.client.common_lib import error, utils, global_config |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 | 112 |
113 def _quick_http_test(self): | 113 def _quick_http_test(self): |
114 """ Run a simple 30 second wget on the repository to see if it is | 114 """ Run a simple 30 second wget on the repository to see if it is |
115 reachable. This avoids the need to wait for a full 10min timeout. | 115 reachable. This avoids the need to wait for a full 10min timeout. |
116 """ | 116 """ |
117 # just make a temp file to write a test fetch into | 117 # just make a temp file to write a test fetch into |
118 mktemp = 'mktemp -u /tmp/tmp.XXXXXX' | 118 mktemp = 'mktemp -u /tmp/tmp.XXXXXX' |
119 dest_file_path = self.run_command(mktemp).stdout.strip() | 119 dest_file_path = self.run_command(mktemp).stdout.strip() |
120 | 120 |
121 try: | 121 try: |
122 # build up a wget command using the server name | 122 # build up a wget command |
123 server_name = urlparse.urlparse(self.url)[1] | 123 http_cmd = self.wget_cmd_pattern % (self.url, dest_file_path) |
124 http_cmd = self.wget_cmd_pattern % (server_name, dest_file_path) | |
125 try: | 124 try: |
126 self.run_command(http_cmd, _run_command_dargs={'timeout': 30}) | 125 self.run_command(http_cmd, _run_command_dargs={'timeout': 30}) |
127 except Exception, e: | 126 except Exception, e: |
128 msg = 'HTTP test failed, unable to contact %s: %s' | 127 msg = 'HTTP test failed, unable to contact %s: %s' |
129 raise error.PackageFetchError(msg % (server_name, e)) | 128 raise error.PackageFetchError(msg % (self.url, e)) |
130 finally: | 129 finally: |
131 self.run_command('rm -rf %s' % dest_file_path) | 130 self.run_command('rm -rf %s' % dest_file_path) |
132 | 131 |
133 | 132 |
134 def fetch_pkg_file(self, filename, dest_path): | 133 def fetch_pkg_file(self, filename, dest_path): |
135 logging.info('Fetching %s from %s to %s', filename, self.url, | 134 logging.info('Fetching %s from %s to %s', filename, self.url, |
136 dest_path) | 135 dest_path) |
137 | 136 |
138 # do a quick test to verify the repo is reachable | 137 # do a quick test to verify the repo is reachable |
139 self._quick_http_test() | 138 self._quick_http_test() |
(...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
853 if not match: | 852 if not match: |
854 return ('', url) | 853 return ('', url) |
855 group, filename = match.groups() | 854 group, filename = match.groups() |
856 # Generate the group prefix. | 855 # Generate the group prefix. |
857 group = re.sub(r'\W', '_', group) | 856 group = re.sub(r'\W', '_', group) |
858 # Drop the extension to get the raw test name. | 857 # Drop the extension to get the raw test name. |
859 testname = re.sub(r'\.tar\.bz2', '', filename) | 858 testname = re.sub(r'\.tar\.bz2', '', filename) |
860 # Drop any random numbers at the end of the test name if any | 859 # Drop any random numbers at the end of the test name if any |
861 testname = re.sub(r'\.(\d*)', '', testname) | 860 testname = re.sub(r'\.(\d*)', '', testname) |
862 return (group, testname) | 861 return (group, testname) |
OLD | NEW |