Commit 1d9a2e3a by murtaugh

added ?remake option to force remake (-B)

1 parent 22b33c94
......@@ -69,7 +69,11 @@ def maker (path, queue):
try:
# _, filename = os.path.split(req['path'])
rpath = os.path.relpath(req['path'], req['cwd'])
cmd = ["make", "-f", req['makefile'], rpath]
cmd = ["make"]
cmd.extend(("-f", req['makefile']))
if 'force' in req:
cmd.append('-B')
cmd.append(rpath)
print ("Make {0} using {1} in {2}".format(rpath, req['makefile'], req['cwd']))
output = subprocess.check_output(cmd, cwd=req['cwd'], stderr=subprocess.STDOUT)
rurl = "/"+os.path.relpath(req['path'], path)+"?lastbuild={0}".format(datetime.datetime.now().isoformat())
......@@ -118,13 +122,14 @@ class FileSaver (Resource):
# return NOT_DONE_YET
class FileMaker (Resource):
def __init__(self, path, makeRequestsQueue, docroot, index="index.html", makefile=None):
def __init__(self, path, makeRequestsQueue, docroot, index="index.html", makefile=None, force=False):
# print ("FileMaker", path, docroot, makefile)
self.path = path
self.makeRequestsQueue = makeRequestsQueue
self.docroot = docroot
self.makefile = makefile
self.index = index
self.force = force
# self.cwd = cwd
Resource.__init__(self)
self.childNotFound = NoResource("File not found.")
......@@ -153,15 +158,16 @@ class FileMaker (Resource):
# print ("fpath:{0}".format(fpath), file=sys.stderr)
r = None
# HOW TO AVOID THIS IF NOT NEEDED ?! >>>> ACTUALLY... or simply don't repeat again below!! (todo)
query = parse_qs2(urlparse(request.uri).query)
if self.makefile:
r = make_question_simple(fpath, self.makefile, self.docroot)
if r == 1:
ret = FileMaker(fpath, self.makeRequestsQueue, self.docroot, self.index, self.makefile)
force = 'remake' in query
if r == 1 or force:
ret = FileMaker(fpath, self.makeRequestsQueue, self.docroot, self.index, self.makefile, force=force)
ret.isLeaf = True
return ret
# print ("FILE", request.path, request.uri, request.method, dir(request), request.getAllHeaders())
# print ("FILE", request.path, request.uri, request.method)
query = parse_qs2(urlparse(request.uri).query)
xRequestedWith = request.getHeader("x-requested-with")
referer = request.getHeader('referer')
# use_editor = False
......@@ -197,7 +203,10 @@ class FileMaker (Resource):
rurl = "/"+rpath+"/"
# print ("rurl: '{0}'".format(rurl), file=sys.stderr)
return redirectTo(rurl, request)
self.makeRequestsQueue.put({'path': self.path, 'request': request, 'makefile': self.makefile, 'cwd': self.docroot})
d = {'path': self.path, 'request': request, 'makefile': self.makefile, 'cwd': self.docroot}
if self.force:
d['force'] = True
self.makeRequestsQueue.put(d)
return NOT_DONE_YET
def getChildForRequest(self, request):
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!