Rev431, Define coveralls rcfile, Escape shell parameters
This commit is contained in:
parent
47dbdc0850
commit
54c367cac8
5 changed files with 41 additions and 16 deletions
|
@ -14,4 +14,4 @@ before_install:
|
|||
- pip install coveralls
|
||||
after_success:
|
||||
- codecov
|
||||
- coveralls
|
||||
- coveralls --rcfile=src/Test/coverage.ini
|
||||
|
|
|
@ -8,7 +8,7 @@ class Config(object):
|
|||
|
||||
def __init__(self, argv):
|
||||
self.version = "0.3.2"
|
||||
self.rev = 427
|
||||
self.rev = 431
|
||||
self.argv = argv
|
||||
self.action = None
|
||||
self.createParser()
|
||||
|
|
|
@ -5,6 +5,7 @@ import ssl
|
|||
|
||||
from Config import config
|
||||
from util import SslPatch
|
||||
from util import utils
|
||||
|
||||
|
||||
class CryptConnectionManager:
|
||||
|
@ -64,8 +65,11 @@ class CryptConnectionManager:
|
|||
return True # Files already exits
|
||||
|
||||
proc = subprocess.Popen(
|
||||
"%s req -x509 -newkey rsa:2048 -sha256 -batch -keyout %s/key-rsa.pem -out %s/cert-rsa.pem -nodes -config %s" % (
|
||||
self.openssl_bin, config.data_dir, config.data_dir, self.openssl_env["OPENSSL_CONF"]
|
||||
"%s req -x509 -newkey rsa:2048 -sha256 -batch -keyout %s -out %s -nodes -config %s" % utils.shellquote(
|
||||
self.openssl_bin,
|
||||
config.data_dir+"/key-rsa.pem",
|
||||
config.data_dir+"/cert-rsa.pem",
|
||||
self.openssl_env["OPENSSL_CONF"]
|
||||
),
|
||||
shell=True, stderr=subprocess.STDOUT, stdout=subprocess.PIPE, env=self.openssl_env
|
||||
)
|
||||
|
@ -95,8 +99,12 @@ class CryptConnectionManager:
|
|||
|
||||
# Create ECC cert
|
||||
proc = subprocess.Popen(
|
||||
"%s req -new -key %s/key-ecc.pem -x509 -nodes -out %s/cert-ecc.pem -config %s" % (
|
||||
self.openssl_bin, config.data_dir, config.data_dir, self.openssl_env["OPENSSL_CONF"]),
|
||||
"%s req -new -key %s -x509 -nodes -out %s -config %s" % utils.shellquote(
|
||||
self.openssl_bin,
|
||||
config.data_dir+"/key-ecc.pem",
|
||||
config.data_dir+"/cert-ecc.pem",
|
||||
self.openssl_env["OPENSSL_CONF"]
|
||||
),
|
||||
shell=True, stderr=subprocess.STDOUT, stdout=subprocess.PIPE, env=self.openssl_env
|
||||
)
|
||||
back = proc.stdout.read().strip()
|
||||
|
|
|
@ -5,6 +5,7 @@ import logging
|
|||
import time
|
||||
|
||||
from Config import config
|
||||
from util import utils
|
||||
|
||||
|
||||
# Find files with extension in path
|
||||
|
@ -22,7 +23,7 @@ def findCoffeescriptCompiler():
|
|||
coffeescript_compiler = None
|
||||
try:
|
||||
import distutils.spawn
|
||||
coffeescript_compiler = distutils.spawn.find_executable("coffee") + " --no-header -p"
|
||||
coffeescript_compiler = utils.shellquote(distutils.spawn.find_executable("coffee")) + " --no-header -p"
|
||||
except:
|
||||
pass
|
||||
if coffeescript_compiler:
|
||||
|
@ -72,18 +73,26 @@ def merge(merged_path):
|
|||
if not config.coffeescript_compiler:
|
||||
logging.error("No coffeescript compiler definied, skipping compiling %s" % merged_path)
|
||||
return False # No coffeescript compiler, skip this file
|
||||
|
||||
# Replace / with os separators and escape it
|
||||
file_path_escaped = utils.shellquote(os.path.join(*file_path.split("/")))
|
||||
|
||||
if "%s" in config.coffeescript_compiler: # Replace %s with coffeescript file
|
||||
command = config.coffeescript_compiler % os.path.join(*file_path.split("/"))
|
||||
command = config.coffeescript_compiler % file_path_escaped
|
||||
else: # Put coffeescript file to end
|
||||
command = config.coffeescript_compiler + " " + os.path.join(*file_path.split("/"))
|
||||
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().decode("utf8")
|
||||
compiler.wait()
|
||||
logging.debug("Running: %s (Done in %.2fs)" % (command, time.time() - s))
|
||||
if out and out.startswith("("):
|
||||
|
||||
# Check errors
|
||||
if out and out.startswith("("): # No error found
|
||||
parts.append(out)
|
||||
else:
|
||||
else: # Put error message in place of source code
|
||||
error = out
|
||||
logging.error("%s Compile error: %s" % (file_path, error))
|
||||
parts.append(
|
||||
|
@ -108,4 +117,4 @@ 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")
|
||||
merge("data/12Hw8rTgzrNo4DSh2AkqwPRqDyTticwJyH/js/all.js")
|
||||
|
|
|
@ -1,7 +1,15 @@
|
|||
import os
|
||||
|
||||
|
||||
def atomicWrite(dest, content, mode="w"):
|
||||
open(dest+"-new", mode).write(content)
|
||||
os.rename(dest, dest+"-old")
|
||||
os.rename(dest+"-new", dest)
|
||||
os.unlink(dest+"-old")
|
||||
open(dest + "-new", mode).write(content)
|
||||
os.rename(dest, dest + "-old")
|
||||
os.rename(dest + "-new", dest)
|
||||
os.unlink(dest + "-old")
|
||||
|
||||
|
||||
def shellquote(*args):
|
||||
if len(args) == 1:
|
||||
return '"%s"' % args[0].replace('"', "")
|
||||
else:
|
||||
return tuple(['"%s"' % arg.replace('"', "") for arg in args])
|
||||
|
|
Loading…
Reference in a new issue