def new(self): if self.subProcess is not None: # may be running if self.subProcess.poll() is None: # is running return """ <html> <head> <link href="/css/bootstrap.min.css" rel="stylesheet"> <link href="/css/bootstrap-theme.min.css" rel="stylesheet"> </head> <body> {} <div class="container"> Currently running. <br/> <a href="stop">stop</a> </div> </body></html> """.format(htmlView.HtmlMenu().__html__()) else: code = self.subProcess.poll() self.subProcess = None self.sentSig = None return """ last process ended with code %d """ % code return """ <html> <head> <link href="/css/bootstrap.min.css" rel="stylesheet"> <link href="/css/bootstrap-theme.min.css" rel="stylesheet"> </head> <body> {} <div class="container" role="main"> <h2>Upload a file</h2> <form action="upload" method="post" enctype="multipart/form-data"> <table cellpadding="3"> <tr> <td align="right"> Configuration file </td> <td> <input type="file" name="myFile" /></td> </tr> <tr> <td align="right"> Runtime (minutes) </td> <td> <input type="text" name="minutes" /> </td> </tr> </table> </br> <input type="submit" /> </form> </div> </body></html> """.format(htmlView.HtmlMenu().__html__())
def upload(self, myFile, minutes): print('upload') filePath = path.join(self.workFolder, 'xlsConfig.xls') with open(filePath, 'wb') as fd: while True: data = myFile.file.read(8192) if not data: break fd.write(data) print('file Saved') print(' '.join([makeSchedulePath, self.workFolder, minutes])) self.subProcess = sp.Popen([makeSchedulePath, self.workFolder, minutes], stdout=open(path.join(self.workFolder, 'stdout'), 'w')) print('process started') return """ <html> <head> <link href="/css/bootstrap.min.css" rel="stylesheet"> <link href="/css/bootstrap-theme.min.css" rel="stylesheet"> </head> <body> {} <div class="container" role="main"> <h2>Started for {} minutes...</h2> </div> </body></html> """.format(htmlView.HtmlMenu().__html__(), minutes)
def index(self): menu = """\ <html> <head> <title>Happy League</title> <link href="/css/bootstrap.min.css" rel="stylesheet"> </head> <body> {} </body> </html> """.format(htmlView.HtmlMenu().__html__()) return menu
def debug(self): return """ <html> <head> <link href="/css/bootstrap.min.css" rel="stylesheet"> <link href="/css/bootstrap-theme.min.css" rel="stylesheet"> </head> <body> {} <div class="container" role="main"> {} </div> </body></html> """.format(htmlView.HtmlMenu().__html__(), '\n'.join(self._formatStdout() + self._formatStdout('stderr', color='red')))
def _buildAnalysisPage(self, builder, refresh=False): if not path.exists(self.schPath): return "no schedule" return """ <html> <head> <link href="/css/bootstrap.min.css" rel="stylesheet"> <link href="/css/bootstrap-theme.min.css" rel="stylesheet"> </head> <body> {} <div class="container" role="main"> No Schedule. </div> </body></html> """.format(htmlView.HtmlMenu().__html__()) config, matchL, optState = read_pickle(self.schPath) doc = htmlView.HtmlDoc(builder(config, matchL, optState)) if refresh: doc.head.add(htmlView.HtmlRefresh()) return doc.__html__()