diff --git a/src/Config.py b/src/Config.py index 057f0485..5fd9c091 100644 --- a/src/Config.py +++ b/src/Config.py @@ -124,11 +124,6 @@ class Config(object): "http://tracker.bt4g.com:2095/announce", # Cloudflare "zero://2602:ffc5::c5b2:5360:26312" # US/ATL ] - # Platform specific - if sys.platform.startswith("win"): - coffeescript = "type %s | tools\\coffee\\coffee.cmd" - else: - coffeescript = None try: language, enc = locale.getdefaultlocale() @@ -336,9 +331,6 @@ class Config(object): self.parser.add_argument("--download_optional", choices=["manual", "auto"], default="manual") - self.parser.add_argument('--coffeescript_compiler', help='Coffeescript compiler for developing', default=coffeescript, - metavar='executable_path') - self.parser.add_argument('--tor', help='enable: Use only for Tor peers, always: Use Tor for every connection', choices=["disable", "enable", "always"], default='enable') self.parser.add_argument('--tor_controller', help='Tor controller address', metavar='ip:port', default='127.0.0.1:9051') self.parser.add_argument('--tor_proxy', help='Tor proxy address', metavar='ip:port', default='127.0.0.1:9050') diff --git a/src/Debug/DebugMedia.py b/src/Debug/DebugMedia.py index a892dc56..25a84be1 100644 --- a/src/Debug/DebugMedia.py +++ b/src/Debug/DebugMedia.py @@ -29,30 +29,13 @@ def findfiles(path, find_ext): yield file_path.replace("\\", "/") -# Try to find coffeescript compiler in path -def findCoffeescriptCompiler(): - coffeescript_compiler = None - try: - import distutils.spawn - coffeescript_compiler = helper.shellquote(distutils.spawn.find_executable("coffee")) + " --no-header -p" - except: - pass - if coffeescript_compiler: - return coffeescript_compiler - else: - return False - - -# Generates: all.js: merge *.js, compile coffeescript, all.css: merge *.css, vendor prefix features +# Generates: all.js: merge *.js, all.css: merge *.css, vendor prefix features def merge(merged_path): merged_path = merged_path.replace("\\", "/") merge_dir = os.path.dirname(merged_path) s = time.time() ext = merged_path.split(".")[-1] - if ext == "js": # If merging .js find .coffee too - find_ext = ["js", "coffee"] - else: - find_ext = [ext] + find_ext = [ext] # If exist check the other files modification date if os.path.isfile(merged_path): @@ -80,44 +63,7 @@ def merge(merged_path): for file_path in findfiles(merge_dir, find_ext): file_relative_path = file_path.replace(merge_dir + "/", "") parts.append(b"\n/* ---- %s ---- */\n\n" % file_relative_path.encode("utf8")) - if file_path.endswith(".coffee"): # Compile coffee script - if file_path in changed or file_relative_path not in old_parts: # Only recompile if changed or its not compiled before - if config.coffeescript_compiler is None: - config.coffeescript_compiler = findCoffeescriptCompiler() - if not config.coffeescript_compiler: - logging.error("No coffeescript compiler defined, skipping compiling %s" % merged_path) - return False # No coffeescript compiler, skip this file - - # Replace / with os separators and escape it - file_path_escaped = helper.shellquote(file_path.replace("/", os.path.sep)) - - if "%s" in config.coffeescript_compiler: # Replace %s with coffeescript file - command = config.coffeescript_compiler.replace("%s", file_path_escaped) - else: # Put coffeescript file to end - command = config.coffeescript_compiler + " " + file_path_escaped - - # Start compiling - s = time.time() - compiler = subprocess.Popen(command, shell=True, stderr=subprocess.STDOUT, stdout=subprocess.PIPE) - out = compiler.stdout.read() - compiler.wait() - logging.debug("Running: %s (Done in %.2fs)" % (command, time.time() - s)) - - # Check errors - if out and out.startswith(b"("): # No error found - parts.append(out) - else: # Put error message in place of source code - error = out - logging.error("%s Compile error: %s" % (file_relative_path, error)) - error_escaped = re.escape(error).replace(b"\n", b"\\n").replace(br"\\n", br"\n") - parts.append( - b"alert('%s compile error: %s');" % - (file_relative_path.encode(), error_escaped) - ) - else: # Not changed use the old_part - parts.append(old_parts[file_relative_path]) - else: # Add to parts - parts.append(open(file_path, "rb").read()) + parts.append(open(file_path, "rb").read()) merged = b"\n".join(parts) if ext == "css": # Vendor prefix css @@ -131,5 +77,4 @@ def merge(merged_path): if __name__ == "__main__": logging.getLogger().setLevel(logging.DEBUG) os.chdir("..") - config.coffeescript_compiler = r'type "%s" | tools\coffee-node\bin\node.exe tools\coffee-node\bin\coffee --no-header -s -p' merge("data/12Hw8rTgzrNo4DSh2AkqwPRqDyTticwJyH/js/all.js")