def _find_sb(directory): sb = sandbox.create_from_within(directory) if not sb: print('%s does not appear to be inside a sandbox.' % os.path.abspath(directory)) sys.exit(1) return sb
def revno(dir): sb = sandbox.create_from_within(dir) revno = int( vcs.revno( sb.get_component_path(sb.get_top_component(), component.CODE_ASPECT_NAME))) #print('revno: {0}'.format(revno)) print(revno) return revno
def getRevision(self): sb = sandbox.create_from_within(self.conf.path) branchLocation = os.path.join(sb.get_code_root(), sb.get_top_component()) return vcs.revno(branchLocation, True) cwd = os.getcwd() os.chdir(branchLocation) p = subprocess.Popen(["bzr", "revno", "--tree"], stdout=subprocess.PIPE) revno = p.stdout.read().strip() os.chdir(cwd) return revno
def getRevision(self): sb = sandbox.create_from_within(self.conf.path) branchLocation = os.path.join(sb.get_code_root(), sb.get_top_component()) return vcs.revno(branchLocation, True) cwd = os.getcwd() os.chdir(branchLocation) p = subprocess.Popen(['bzr', 'revno', '--tree'], stdout=subprocess.PIPE) revno = p.stdout.read().strip() os.chdir(cwd) return revno
def main(argv): err = 0 args, args_options, builder, builder_options = parse_args(argv) sb = sandbox.create_from_within(args_options.sandbox) # Is this a buildable sandbox? if component.CODE_ASPECT_NAME not in sb.get_component_aspects( sb.get_top_component()): builder = _SimulatedBuilder(True) else: if not builder_options.build_type: builder_options.build_type = sb.get_build_config() else: sb.set_build_config(builder_options.build_type) builder_options.quick = args_options.quick args_options.assemble_only = args_options.assemble_only and os.path.isdir( sb.get_built_root()) if args_options.dry_run: builder = _SimulatedBuilder() else: # If cmdline specified a builder name, look up the corresponding object. # Otherwise, select default one. if builder: builder = _builders[builder] else: builder = select_builder(sb) if not builder: if not os.path.isdir(sb.get_code_root()): # User has requested a built sandbox -- now requesting that it be runnable! args_options.assemble_only = True else: print('No build tool supports {0}.'.format( sb.get_code_root())) return 2 print('Using {0} as build tool.'.format(builder.get_name())) if not args: args = ['build'] if args_options.auto: if sb.get_component_reused_aspect( sb.get_top_component()) != component.CODE_ASPECT_NAME: print("Can't auto-build if top component is pre-built.") err = 1 else: auto_build(sb, args_options, args, builder, builder_options) else: err = do_build(sb, args_options, args, builder, builder_options) return err
def main(argv): err = 0 args, args_options, builder, builder_options = parse_args(argv) sb = sandbox.create_from_within(args_options.sandbox) # Is this a buildable sandbox? if component.CODE_ASPECT_NAME not in sb.get_component_aspects(sb.get_top_component()): builder = _SimulatedBuilder(True) else: if not builder_options.build_type: builder_options.build_type = sb.get_build_config() else: sb.set_build_config(builder_options.build_type) builder_options.quick = args_options.quick args_options.assemble_only = args_options.assemble_only and os.path.isdir(sb.get_built_root()) if args_options.dry_run: builder = _SimulatedBuilder() else: # If cmdline specified a builder name, look up the corresponding object. # Otherwise, select default one. if builder: builder = _builders[builder] else: builder = select_builder(sb) if not builder: if not os.path.isdir(sb.get_code_root()): # User has requested a built sandbox -- now requesting that it be runnable! args_options.assemble_only = True else: print('No build tool supports {0}.'.format(sb.get_code_root())) return 2 print('Using {0} as build tool.'.format(builder.get_name())) if not args: args = ['build'] if args_options.auto: if sb.get_component_reused_aspect(sb.get_top_component()) != component.CODE_ASPECT_NAME: print("Can't auto-build if top component is pre-built.") err = 1 else: auto_build(sb, args_options, args, builder, builder_options) else: err = do_build(sb, args_options, args, builder, builder_options) return err
def main(argv): print("Minifying files") args, args_options = parse_args(argv) sb = sandbox.create_from_within(args_options.sandbox) br = sb.get_built_root() types = [ 'adminportal', 'uibase', 'search' ] for type in types: try: mini = Minifier(type, br) mini.do_minify() except: print "Minify error calling jsmin:\n%s" % sys.exc_info()[0] raise print("Minify succeeded")
def main(argv): print("Minifying files") args, args_options = parse_args(argv) sb = sandbox.create_from_within(args_options.sandbox) br = sb.get_built_root() types = ['adminportal', 'uibase', 'search'] for type in types: try: mini = Minifier(type, br) mini.do_minify() except: print "Minify error calling jsmin:\n%s" % sys.exc_info()[0] raise print("Minify succeeded")
def get_branch(self): return sandbox.create_from_within(self.conf.path).get_branch()
def getProject(self): return sandbox.create_from_within(self.conf.path).get_top_component()
def revno(dir): sb = sandbox.create_from_within(dir) revno = int(vcs.revno(sb.get_component_path(sb.get_top_component(), component.CODE_ASPECT_NAME))) #print('revno: {0}'.format(revno)) print(revno) return revno
def get_db(which): return Dashboard(sandbox.create_from_within(os.path.join(TEST_ROOT_DIR, 'x.trunk.' + which)).get_report_root())
def find(self, path): for key in self.formatErrors: print ("%s%s\n" % (path, key)) for line in self.formatErrors[key]: printc( WARNING_COLOR + "Please change to the correct format specifiers on line %d." % line.fileLocs[0].line + ERROR_COLOR ) printc("%s\n" % line.id + NORMTXT) printc(CMD_COLOR + "".rjust(80, "*") + NORMTXT) doNotExtract = open(path + ".do-not-extract.txt", "a") num = 0 ff = FakeFile() for key in self.possibleMisses: num += len(self.possibleMisses[key]) try: try: print ("%d possible missed strings." % num) fileNum = 1 for key in self.possibleMisses: printc(CMD_COLOR + "\nFile %d of %d Files" % (fileNum, len(self.possibleMisses)) + NORMTXT) fileNum += 1 ff.printf("%s%s\n" % (path, key)) printc(CMD_COLOR + "%s possible misses in this file.\n" % len(self.possibleMisses[key]) + NORMTXT) f = open(path + "/" + key, "r+") lines = f.readlines() for miss in self.possibleMisses[key]: start = lines[miss.fileLocs[0].line - 1].find(miss.id) - 1 end = start + len(miss.id) + 2 autoCorrect = ["text:\s?", "header:\s?", "title:\s?", "msg:\s?", "label:\s?"] auto = False for ac in autoCorrect: correct = re.compile(r"%s" % ac, re.IGNORECASE) if correct.search(lines[miss.fileLocs[0].line - 1][start - len(ac) : start]): ff.printf( "Auto change (from-to) line %s\n %s" % (miss.fileLocs[0].line, lines[miss.fileLocs[0].line - 1].strip()) ) line = lines[miss.fileLocs[0].line - 1] lines[miss.fileLocs[0].line - 1] = ( line[0:start] + "_(" + line[start:end] + ")" + line[end : len(line)] ) ff.printf("%s\n" % lines[miss.fileLocs[0].line - 1].strip()) f.seek(0) f.writelines(lines) auto = True break if auto: continue answer = "" while not answer: printc( DELIM_COLOR + "%s %s" % (miss.fileLocs[0].line - 1, lines[miss.fileLocs[0].line - 2].strip()) + NORMTXT ) printc( DELIM_COLOR + str(miss.fileLocs[0].line) + " " + TITLE_COLOR + lines[miss.fileLocs[0].line - 1][0:start].lstrip() + WARNING_COLOR + lines[miss.fileLocs[0].line - 1][start:end] + TITLE_COLOR + lines[miss.fileLocs[0].line - 1][end : len(lines[miss.fileLocs[0].line - 1])] + NORMTXT ) if miss.fileLocs[0].line < len(lines): printc( DELIM_COLOR + "%s %s" % (miss.fileLocs[0].line + 1, lines[miss.fileLocs[0].line].strip()) + NORMTXT ) print ("") answer = raw_input( "Is this string suppose to be translated {(y)es/(n)o/(s)kip/(e)dit}?[s]\n%s\t: " % miss.id ) print ("") if answer == "": answer = "s" if "ty1".find(answer.lower()[0]) != -1: ff.write( "Auto change (from-to) line %s\n %s" % (miss.fileLocs[0].line, lines[miss.fileLocs[0].line - 1].strip()) ) line = lines[miss.fileLocs[0].line - 1] lines[miss.fileLocs[0].line - 1] = ( line[0:start] + "_(" + line[start:end] + ")" + line[end : len(line)] ) ff.write("%s\n" % lines[miss.fileLocs[0].line - 1].strip()) f.seek(0) f.writelines(lines) elif "fn0".find(answer.lower()[0]) != -1: doNotExtract.write(miss.id + "\n") elif "s".find(answer.lower()[0]) != -1: pass elif "e".find(answer.lower()[0]) != -1: if os.name == "nt": os.system("start notepad %s" % ("%s/%s" % (path, key))) else: os.system("vi -R %s" % ("%s/%s" % (path, key))) else: print ("Not a vaild response") answer = "" f.close() except KeyboardInterrupt: f.close() finally: sb = sandbox.create_from_within(path) if not os.path.exists(os.path.join(sb.get_root(), "translations")): os.mkdir(os.path.join(sb.get_root(), "translations")) cl = open(os.path.join(sb.get_root(), "translations", "LocChanges.log"), "w") cl.write(ff.txt) doNotExtract.close()
subject = '%s build of %s on %s %s.' % (sb.get_variant(), sb.get_top_component(), bi.host, status) arguments = '--to %s --sender sadm --subject "%s" --host smtp.example.com --port 587' % (emails, subject) # TODO KIM TO CONF arguments += ' --username [email protected] --password password' # TODO KIM TO CONF if body: arguments += ' --body "%s"' % body os.system('python %s/buildscripts/mailout.py %s' % (sb.get_code_root(), arguments)) if not state.err: state.reason = '' if _should_report(sb, options): report(sb, state) else: print('Skipping report phase.') return state.err if __name__ == '__main__': import sys parser = _define_options() options, args = parser.parse_args(sys.argv) try: sb = sandbox.create_from_within(options.sandbox) if not sb: print('%s does not appear to be inside a sandbox.' % os.path.abspath(options.sandbox)) err = 1 else: err = evaluate(sb, options) except: traceback.print_exc() err = 1 sys.exit(err)
arguments += ' --username [email protected] --password password' # TODO KIM TO CONF if body: arguments += ' --body "%s"' % body os.system('python %s/buildscripts/mailout.py %s' % (sb.get_code_root(), arguments)) if not state.err: state.reason = '' if _should_report(sb, options): report(sb, state) else: print('Skipping report phase.') return state.err if __name__ == '__main__': import sys parser = _define_options() options, args = parser.parse_args(sys.argv) try: sb = sandbox.create_from_within(options.sandbox) if not sb: print('%s does not appear to be inside a sandbox.' % os.path.abspath(options.sandbox)) err = 1 else: err = evaluate(sb, options) except: traceback.print_exc() err = 1 sys.exit(err)
stdin=subprocess.PIPE, stderr=subprocess.STDOUT, cwd=os.path.dirname(__file__)) if cmd.find('wmic') > -1: (stdout, stderr) = p.communicate(com) # Sometimes a process waits for its stdout to be read before it will exit. # Therefore, attempt to read before we wait for exit. out = p.stdout.read() # Now wait for process to exit. exitcode = p.wait() # Append any other text that accumulated. if cmd.find('wmic') > -1: out += stdout else: out += p.stdout.read() except Exception: out = str(sys.exc_value) exitcode = -1 if not acceptFailure: raise return (out, exitcode) if __name__ == "__main__": import sandbox if len(sys.argv) > 1: sb = sandbox.create_from_within(sys.argv[1]) else: sb = sandbox.current sb.check_tools()
def find(self, path): for key in self.formatErrors: print('%s%s\n' % (path, key)) for line in self.formatErrors[key]: printc( WARNING_COLOR + 'Please change to the correct format specifiers on line %d.' % line.fileLocs[0].line + ERROR_COLOR) printc("%s\n" % line.id + NORMTXT) printc(CMD_COLOR + ''.rjust(80, '*') + NORMTXT) doNotExtract = open(path + '.do-not-extract.txt', 'a') num = 0 ff = FakeFile() for key in self.possibleMisses: num += len(self.possibleMisses[key]) try: try: print("%d possible missed strings." % num) fileNum = 1 for key in self.possibleMisses: printc(CMD_COLOR + '\nFile %d of %d Files' % (fileNum, len(self.possibleMisses)) + NORMTXT) fileNum += 1 ff.printf('%s%s\n' % (path, key)) printc(CMD_COLOR + '%s possible misses in this file.\n' % len(self.possibleMisses[key]) + NORMTXT) f = open(path + '/' + key, 'r+') lines = f.readlines() for miss in self.possibleMisses[key]: start = lines[miss.fileLocs[0].line - 1].find( miss.id) - 1 end = start + len(miss.id) + 2 autoCorrect = [ 'text:\s?', 'header:\s?', 'title:\s?', 'msg:\s?', 'label:\s?' ] auto = False for ac in autoCorrect: correct = re.compile(r'%s' % ac, re.IGNORECASE) if correct.search(lines[miss.fileLocs[0].line - 1][start - len(ac):start]): ff.printf( 'Auto change (from-to) line %s\n %s' % (miss.fileLocs[0].line, lines[miss.fileLocs[0].line - 1].strip())) line = lines[miss.fileLocs[0].line - 1] lines[ miss.fileLocs[0].line - 1] = line[0:start] + '_(' + line[ start:end] + ')' + line[end:len(line)] ff.printf( '%s\n' % lines[miss.fileLocs[0].line - 1].strip()) f.seek(0) f.writelines(lines) auto = True break if auto: continue answer = '' while not answer: printc(DELIM_COLOR + '%s %s' % (miss.fileLocs[0].line - 1, lines[miss.fileLocs[0].line - 2].strip()) + NORMTXT) printc( DELIM_COLOR + str(miss.fileLocs[0].line) + ' ' + TITLE_COLOR + lines[miss.fileLocs[0].line - 1][0:start].lstrip() + WARNING_COLOR + lines[miss.fileLocs[0].line - 1][start:end] + TITLE_COLOR + lines[miss.fileLocs[0].line - 1][end:len(lines[miss.fileLocs[0].line - 1])] + NORMTXT) if miss.fileLocs[0].line < len(lines): printc(DELIM_COLOR + '%s %s' % (miss.fileLocs[0].line + 1, lines[miss.fileLocs[0].line].strip()) + NORMTXT) print('') answer = raw_input( 'Is this string suppose to be translated {(y)es/(n)o/(s)kip/(e)dit}?[s]\n%s\t: ' % miss.id) print('') if answer == '': answer = 's' if 'ty1'.find(answer.lower()[0]) != -1: ff.write( 'Auto change (from-to) line %s\n %s' % (miss.fileLocs[0].line, lines[miss.fileLocs[0].line - 1].strip())) line = lines[miss.fileLocs[0].line - 1] lines[ miss.fileLocs[0].line - 1] = line[0:start] + '_(' + line[ start:end] + ')' + line[end:len(line)] ff.write( '%s\n' % lines[miss.fileLocs[0].line - 1].strip()) f.seek(0) f.writelines(lines) elif 'fn0'.find(answer.lower()[0]) != -1: doNotExtract.write(miss.id + '\n') elif 's'.find(answer.lower()[0]) != -1: pass elif 'e'.find(answer.lower()[0]) != -1: if os.name == 'nt': os.system('start notepad %s' % ('%s/%s' % (path, key))) else: os.system('vi -R %s' % ('%s/%s' % (path, key))) else: print('Not a vaild response') answer = '' f.close() except KeyboardInterrupt: f.close() finally: sb = sandbox.create_from_within(path) if not os.path.exists(os.path.join(sb.get_root(), 'translations')): os.mkdir(os.path.join(sb.get_root(), 'translations')) cl = open( os.path.join(sb.get_root(), 'translations', 'LocChanges.log'), 'w') cl.write(ff.txt) doNotExtract.close()
args = shlex.split(cmd) else: args = cmd p = subprocess.Popen(args, stdout=subprocess.PIPE, shell=useShell, stdin=subprocess.PIPE, stderr=subprocess.STDOUT, cwd=os.path.dirname(__file__)) if cmd.find('wmic') > -1: (stdout, stderr) = p.communicate(com) # Sometimes a process waits for its stdout to be read before it will exit. # Therefore, attempt to read before we wait for exit. out = p.stdout.read() # Now wait for process to exit. exitcode = p.wait() # Append any other text that accumulated. if cmd.find('wmic') > -1: out += stdout else: out += p.stdout.read() except Exception: out = str(sys.exc_value) exitcode = -1 if not acceptFailure: raise return (out, exitcode) if __name__ == "__main__": import sandbox if len(sys.argv) > 1: sb = sandbox.create_from_within(sys.argv[1]) else: sb = sandbox.current sb.check_tools()