def gen_mock_data() : requires = [] for data_file in config.MOCK_DATA_FILES : lines = helper.get_file_lines(data_file, True) for line in lines : if line.find('goog.provide(') == 0 : line = 'goog.require' + line[line.rfind('(') :] requires.append(line) break requires.sort() input_lines = helper.get_file_lines(config.JS_FBAPI_FILE_PATH) output_lines = [] provide_line = None for line in input_lines : stripped_line = line.strip() if stripped_line.find('goog.provide(') == 0 : provide_line = stripped_line elif stripped_line.find('goog.require(') == 0 : if not stripped_line in requires : requires.append(stripped_line) else : output_lines.append(line) requires.sort() output_text = '%s\n\n%s\n\n%s' % ( provide_line, '\n'.join(requires), ''.join(output_lines) ) helper.write_text(config.JS_FBAPI_FILE_PATH, output_text)
def gen_js_bin_deps(target_name, module_files) : output_path = '%s/%s.txt' % (config.JS_DEPS_OUTPUT_DIR, target_name) output_str = ('-o list > %s ' % output_path) cmd = gen_base_cmd(module_files) + output_str print cmd os.system(cmd) lines = helper.get_file_lines(output_path, True) new_lines = [] idx = 0 last_module_name = None for line in lines : line = line.strip() new_lines.append('--js %s' % line) idx = idx + 1 if line in module_files : module_name = helper.get_module_name(line) if last_module_name is None : new_lines.append('--module %s:%s' % (module_name, idx)) else : new_lines.append( '--module %s:%s:%s' % (module_name, idx, last_module_name)) last_module_name = module_name idx = 0 helper.write_text(output_path, '\n'.join(new_lines))
def build_js(target_name, flags): input_path = "%s/%s.txt" % (config.JS_DEPS_OUTPUT_DIR, target_name) flags_text = "".join(["%s \\\n" % str(flag) for flag in flags]) cmd = "java -jar %s %s %s " % ( config.JS_COMPILER_PATH, flags_text, " \\\n".join(helper.get_file_lines(input_path, True)), ) print cmd os.system(cmd)
def run_app(use_local_host) : ifconfig_path = '%s/ifconfig.info' % config.BUILD_INFO_DIR os.system('ifconfig > %s' % ifconfig_path) lines = helper.get_file_lines(ifconfig_path, True) ip = '127.0.0.1' if not use_local_host : for line in lines : idx0 = line.find('127.0') idx1 = line.find('inet ') idx2 = line.find(' netmask ') if idx0 == -1 and idx1 == 0 and idx2 > 0 : ip = line[(idx1 + 5) :idx2] break print '-' * 80 print '\n\nhttp://%s:9999/demo/scroller\n\n' % ip print '-' * 80 cmd = 'dev_appserver.py --address=%s --debug --port=9999 application;' % ip print cmd os.system(cmd)