comparison mxtool/mx.py @ 13968:6c6d1eacc398

mxtool: fix pylint 1.1.0 warnings
author Bernhard Urban <bernhard.urban@jku.at>
date Mon, 17 Feb 2014 23:18:00 +0100
parents b076b5c13c3f
children b167b1838029
comparison
equal deleted inserted replaced
13967:4cd7c6629841 13968:6c6d1eacc398
378 includedInJDK = getattr(self, 'includedInJDK', None) 378 includedInJDK = getattr(self, 'includedInJDK', None)
379 if includedInJDK and java().javaCompliance >= JavaCompliance(includedInJDK): 379 if includedInJDK and java().javaCompliance >= JavaCompliance(includedInJDK):
380 return None 380 return None
381 if resolve and self.mustExist and not exists(path): 381 if resolve and self.mustExist and not exists(path):
382 assert not len(self.urls) == 0, 'cannot find required library ' + self.name + ' ' + path 382 assert not len(self.urls) == 0, 'cannot find required library ' + self.name + ' ' + path
383 print('Downloading ' + self.name + ' from ' + str(self.urls)) 383 print 'Downloading ' + self.name + ' from ' + str(self.urls)
384 download(path, self.urls) 384 download(path, self.urls)
385 return path 385 return path
386 386
387 def get_source_path(self, resolve): 387 def get_source_path(self, resolve):
388 path = self.sourcePath 388 path = self.sourcePath
389 if path is None: 389 if path is None:
390 return None 390 return None
391 if not isabs(path): 391 if not isabs(path):
392 path = join(self.suite.dir, path) 392 path = join(self.suite.dir, path)
393 if resolve and len(self.sourceUrls) != 0 and not exists(path): 393 if resolve and len(self.sourceUrls) != 0 and not exists(path):
394 print('Downloading sources for ' + self.name + ' from ' + str(self.sourceUrls)) 394 print 'Downloading sources for ' + self.name + ' from ' + str(self.sourceUrls)
395 download(path, self.sourceUrls) 395 download(path, self.sourceUrls)
396 return path 396 return path
397 397
398 def append_to_classpath(self, cp, resolve): 398 def append_to_classpath(self, cp, resolve):
399 path = self.get_path(resolve) 399 path = self.get_path(resolve)
724 724
725 def xml(self, indent='', newl='', escape=False, standalone=None): 725 def xml(self, indent='', newl='', escape=False, standalone=None):
726 assert self.current == self 726 assert self.current == self
727 result = self.toprettyxml(indent, newl, encoding="UTF-8") 727 result = self.toprettyxml(indent, newl, encoding="UTF-8")
728 if escape: 728 if escape:
729 entities = { '"': "&quot;", "'": "&apos;", '\n': '&#10;' } 729 entities = {'"': "&quot;", "'": "&apos;", '\n': '&#10;'}
730 result = xml.sax.saxutils.escape(result, entities) 730 result = xml.sax.saxutils.escape(result, entities)
731 if standalone is not None: 731 if standalone is not None:
732 result = result.replace('encoding="UTF-8"?>', 'encoding="UTF-8" standalone="' + str(standalone) + '"?>') 732 result = result.replace('encoding="UTF-8"?>', 'encoding="UTF-8" standalone="' + str(standalone) + '"?>')
733 return result 733 return result
734 734
1096 delay = min(delay * 2, remaining, .05) 1096 delay = min(delay * 2, remaining, .05)
1097 time.sleep(delay) 1097 time.sleep(delay)
1098 1098
1099 # Makes the current subprocess accessible to the abort() function 1099 # Makes the current subprocess accessible to the abort() function
1100 # This is a tuple of the Popen object and args. 1100 # This is a tuple of the Popen object and args.
1101 _currentSubprocess = None 1101 _currentSubprocess = (None, None)
1102 1102
1103 def waitOn(p): 1103 def waitOn(p):
1104 if get_os() == 'windows': 1104 if get_os() == 'windows':
1105 # on windows use a poll loop, otherwise signal does not get handled 1105 # on windows use a poll loop, otherwise signal does not get handled
1106 retcode = None 1106 retcode = None
1177 raise e 1177 raise e
1178 abort(e.errno) 1178 abort(e.errno)
1179 except KeyboardInterrupt: 1179 except KeyboardInterrupt:
1180 abort(1) 1180 abort(1)
1181 finally: 1181 finally:
1182 _currentSubprocess = None 1182 _currentSubprocess = (None, None)
1183 1183
1184 if retcode and nonZeroIsFatal: 1184 if retcode and nonZeroIsFatal:
1185 if _opts.verbose: 1185 if _opts.verbose:
1186 if _opts.very_verbose: 1186 if _opts.very_verbose:
1187 raise subprocess.CalledProcessError(retcode, ' '.join(args)) 1187 raise subprocess.CalledProcessError(retcode, ' '.join(args))
1258 def __init__(self, ver): 1258 def __init__(self, ver):
1259 m = re.match(r'1\.(\d+).*', ver) 1259 m = re.match(r'1\.(\d+).*', ver)
1260 assert m is not None, 'not a recognized version string: ' + ver 1260 assert m is not None, 'not a recognized version string: ' + ver
1261 self.value = int(m.group(1)) 1261 self.value = int(m.group(1))
1262 1262
1263 def __str__ (self): 1263 def __str__(self):
1264 return '1.' + str(self.value) 1264 return '1.' + str(self.value)
1265 1265
1266 def __cmp__ (self, other): 1266 def __cmp__(self, other):
1267 if isinstance(other, types.StringType): 1267 if isinstance(other, types.StringType):
1268 other = JavaCompliance(other) 1268 other = JavaCompliance(other)
1269 1269
1270 return cmp(self.value, other.value) 1270 return cmp(self.value, other.value)
1271 1271
1436 the object's value is printed and the exit status is one. 1436 the object's value is printed and the exit status is one.
1437 """ 1437 """
1438 1438
1439 # import traceback 1439 # import traceback
1440 # traceback.print_stack() 1440 # traceback.print_stack()
1441 currentSubprocess = _currentSubprocess 1441 p, _ = _currentSubprocess
1442 if currentSubprocess is not None: 1442 if p is not None:
1443 p, _ = currentSubprocess
1444 if get_os() == 'windows': 1443 if get_os() == 'windows':
1445 p.kill() 1444 p.kill()
1446 else: 1445 else:
1447 _kill_process_group(p.pid) 1446 _kill_process_group(p.pid)
1448 1447
1469 if run([java().java, '-cp', myDir, 'URLConnectionDownload', path] + urls, nonZeroIsFatal=False) == 0: 1468 if run([java().java, '-cp', myDir, 'URLConnectionDownload', path] + urls, nonZeroIsFatal=False) == 0:
1470 return 1469 return
1471 1470
1472 def url_open(url): 1471 def url_open(url):
1473 userAgent = 'Mozilla/5.0 (compatible)' 1472 userAgent = 'Mozilla/5.0 (compatible)'
1474 headers = { 'User-Agent' : userAgent } 1473 headers = {'User-Agent' : userAgent}
1475 req = urllib2.Request(url, headers=headers) 1474 req = urllib2.Request(url, headers=headers)
1476 return urllib2.urlopen(req) 1475 return urllib2.urlopen(req)
1477 1476
1478 for url in urls: 1477 for url in urls:
1479 try: 1478 try:
1480 if (verbose): 1479 if verbose:
1481 log('Downloading ' + url + ' to ' + path) 1480 log('Downloading ' + url + ' to ' + path)
1482 if url.startswith('zip:') or url.startswith('jar:'): 1481 if url.startswith('zip:') or url.startswith('jar:'):
1483 i = url.find('!/') 1482 i = url.find('!/')
1484 if i == -1: 1483 if i == -1:
1485 abort('Zip or jar URL does not contain "!/": ' + url) 1484 abort('Zip or jar URL does not contain "!/": ' + url)
1763 1762
1764 jdtArgs = [java().java, '-Xmx1g'] 1763 jdtArgs = [java().java, '-Xmx1g']
1765 if java().debug_port is not None: 1764 if java().debug_port is not None:
1766 jdtArgs += ['-Xdebug', '-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=' + str(java().debug_port)] 1765 jdtArgs += ['-Xdebug', '-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=' + str(java().debug_port)]
1767 1766
1768 jdtArgs += [ '-jar', jdtJar, 1767 jdtArgs += ['-jar', jdtJar,
1769 '-' + compliance, 1768 '-' + compliance,
1770 '-cp', cp, '-g', '-enableJavadoc', 1769 '-cp', cp, '-g', '-enableJavadoc',
1771 '-d', outputDir] 1770 '-d', outputDir]
1772 jdtArgs += processorArgs 1771 jdtArgs += processorArgs
1773 1772
2282 while len(javafilelist) != 0: 2281 while len(javafilelist) != 0:
2283 i = 0 2282 i = 0
2284 size = 0 2283 size = 0
2285 while i < len(javafilelist): 2284 while i < len(javafilelist):
2286 s = len(javafilelist[i]) + 1 2285 s = len(javafilelist[i]) + 1
2287 if (size + s < 30000): 2286 if size + s < 30000:
2288 size += s 2287 size += s
2289 i += 1 2288 i += 1
2290 else: 2289 else:
2291 break 2290 break
2292 2291
2855 launchOut = XMLDoc() 2854 launchOut = XMLDoc()
2856 consoleOn = 'true' if logToConsole else 'false' 2855 consoleOn = 'true' if logToConsole else 'false'
2857 launchOut.open('launchConfiguration', {'type' : 'org.eclipse.ui.externaltools.ProgramBuilderLaunchConfigurationType'}) 2856 launchOut.open('launchConfiguration', {'type' : 'org.eclipse.ui.externaltools.ProgramBuilderLaunchConfigurationType'})
2858 launchOut.element('booleanAttribute', {'key' : 'org.eclipse.debug.core.capture_output', 'value': consoleOn}) 2857 launchOut.element('booleanAttribute', {'key' : 'org.eclipse.debug.core.capture_output', 'value': consoleOn})
2859 launchOut.open('mapAttribute', {'key' : 'org.eclipse.debug.core.environmentVariables'}) 2858 launchOut.open('mapAttribute', {'key' : 'org.eclipse.debug.core.environmentVariables'})
2860 launchOut.element('mapEntry', {'key' : 'JAVA_HOME', 'value' : java().jdk}) 2859 launchOut.element('mapEntry', {'key' : 'JAVA_HOME', 'value' : java().jdk})
2861 launchOut.close('mapAttribute') 2860 launchOut.close('mapAttribute')
2862 2861
2863 if refresh: 2862 if refresh:
2864 if refreshFile is None: 2863 if refreshFile is None:
2865 refreshScope = '${project}' 2864 refreshScope = '${project}'
2977 split = os.path.split(wsdir) 2976 split = os.path.split(wsdir)
2978 if split[0] == wsdir: # root directory 2977 if split[0] == wsdir: # root directory
2979 return None 2978 return None
2980 else: 2979 else:
2981 return _find_eclipse_wsroot(split[0]) 2980 return _find_eclipse_wsroot(split[0])
2982
2983 def _foobar(val):
2984 print(val)
2985 2981
2986 def _make_workingset_xml(workingSets): 2982 def _make_workingset_xml(workingSets):
2987 wsdoc = XMLDoc() 2983 wsdoc = XMLDoc()
2988 wsdoc.open('workingSetManager') 2984 wsdoc.open('workingSetManager')
2989 2985
3116 out = XMLDoc() 3112 out = XMLDoc()
3117 out.open('project', {'name' : p.name, 'default' : 'default', 'basedir' : '.'}) 3113 out.open('project', {'name' : p.name, 'default' : 'default', 'basedir' : '.'})
3118 out.element('description', data='Builds, tests, and runs the project ' + p.name + '.') 3114 out.element('description', data='Builds, tests, and runs the project ' + p.name + '.')
3119 out.element('import', {'file' : 'nbproject/build-impl.xml'}) 3115 out.element('import', {'file' : 'nbproject/build-impl.xml'})
3120 out.open('target', {'name' : '-post-compile'}) 3116 out.open('target', {'name' : '-post-compile'})
3121 out.open('exec', { 'executable' : sys.executable}) 3117 out.open('exec', {'executable' : sys.executable})
3122 out.element('env', {'key' : 'JAVA_HOME', 'value' : java().jdk}) 3118 out.element('env', {'key' : 'JAVA_HOME', 'value' : java().jdk})
3123 out.element('arg', {'value' : os.path.abspath(__file__)}) 3119 out.element('arg', {'value' : os.path.abspath(__file__)})
3124 out.element('arg', {'value' : 'archive'}) 3120 out.element('arg', {'value' : 'archive'})
3125 out.element('arg', {'value' : '@GRAAL'}) 3121 out.element('arg', {'value' : '@GRAAL'})
3126 out.close('exec') 3122 out.close('exec')
3897 warn("redefining command '" + key + "' in suite " + suite.name) 3893 warn("redefining command '" + key + "' in suite " + suite.name)
3898 _commands[key] = value 3894 _commands[key] = value
3899 3895
3900 def warn(msg): 3896 def warn(msg):
3901 if _warn: 3897 if _warn:
3902 print('WARNING: ' + msg) 3898 print 'WARNING: ' + msg
3903 3899
3904 # Table of commands in alphabetical order. 3900 # Table of commands in alphabetical order.
3905 # Keys are command names, value are lists: [<function>, <usage msg>, <format args to doc string of function>...] 3901 # Keys are command names, value are lists: [<function>, <usage msg>, <format args to doc string of function>...]
3906 # If any of the format args are instances of Callable, then they are called with an 'env' are before being 3902 # If any of the format args are instances of Callable, then they are called with an 'env' are before being
3907 # used in the call to str.format(). 3903 # used in the call to str.format().