def __init__(self, body=u"$text", header=u"", footer=u"", headings=u'$heading\n', preverse=""): self.header = str_template(header) self.body = str_template(body) self.footer = str_template(footer) self.headings = str_template(headings) self.preverse = str_template(preverse)
def hwaf_run_cmd_with_runtime_env(ctx, cmds): # make sure we build first" # waflib.Scripting.run_command('install') import os import tempfile import textwrap #env = ctx.env cwd = os.getcwd() # get the runtime... env = _hwaf_get_runtime_env(ctx) # retrieve the directory from which to run the command ishell_cwd = os.environ.get('HWAF_WAF_SHELL_CWD', cwd) for k in env: v = env[k] if not isinstance(v, str): ctx.fatal('env[%s]=%r (%s)' % (k,v,type(v))) pass pass shell_cmd = cmds[:] import pipes # FIXME: use shlex.quote when available ? from string import Template as str_template cmds=' '.join(pipes.quote(str_template(s).safe_substitute(env)) for s in cmds) retval = subprocess.Popen( cmds, env=env, cwd=ishell_cwd, shell=True, ).wait() if retval: signame = None if retval < 0: # signal? import signal for name, val in vars(signal).items(): if len(name) > 3 and name[:3] == 'SIG' and name[3] != '_': if val == -retval: signame = name break if signame: raise waflib.Errors.WafError( "Command '%s' terminated with signal %s." % (cmds, signame)) else: raise waflib.Errors.WafError( "Command '%s' exited with code %i" % (cmds, retval)) pass return retval
response = "{booking_message}\n\n00. Back".format( booking_message=church.booking_message_label) return HttpResponse(response) if node_name == "BookingConfirmation": # Create booking request # http://0.0.0.0:8000/ussd/?ussd_msisdn=27730174671&ussd_node_name=Confirmation&ussd_response_Home=1&ussd_response_Address=TestLoc&ussd_response_DateTime=TestDatetime cars_no = request.GET.get("ussd_response_BookingSubject") address = request.GET.get("ussd_response_BookingMessage") update = church.booking_submission_message if update.fetch_url: url = str_template(update.url).substitute(full_request) logger.info(url) response = requests.get(url, ussd_session.request) response = response.content else: msg_admin = "" \ "{cars_no}\n" \ "{address}\n"\ "By:{cell_no} @ {time_now}\n".format(cars_no=cars_no, address=address, cell_no=msisdn, time_now=str(timezone.now())[:16])[:160] for admin in church.admin.all(): send_sms(msg_admin, admin.notification_msisdn) response = update.description