示例#1
0
def test_common_datetime():
    ts = time.time()
    dts = datetime.datetime.fromtimestamp(ts)
    hts = get_client_sdatetime(ts)
    assert dts.replace(microsecond=0) == parse_sdatetime(hts)

    import pytz
    sdt = datetime.datetime(2015, 1, 1, 0, 0, 0, 0)
    cdt = convert_server_time_to_client(sdt, pytz.UTC,
                                        pytz.timezone('Asia/Seoul'))
    assert '2015-01-01 09:00:00' == cdt.strftime('%Y-%m-%d %H:%M:%S')
示例#2
0
文件: manifest.py 项目: haje01/wzdat
        try:
            nr.run_notebook()
        except NotebookError, e:
            merr = unicode(e)
            logging.error(merr)
        else:
            with codecs.open(self._path, 'w', 'utf8') as fp:
                write(nr.nb, fp, IPYNB_VER)

        # clear surplus info
        first_cell = nr.nb['cells'][0]
        first_cell['outputs'] = []
        del nr.nb['cells'][1:]

        last_run = datetime.fromtimestamp(time.time())
        last_run = convert_server_time_to_client(last_run)
        last_run = last_run.strftime("%Y-%m-%d %H:%M:%S")
        body = ['    "last_run": "{}"'.format(last_run)]
        body.append('    "elapsed": "{}"'.format(elapsed))
        body.append('    "max_memory": "{}"'.format(sizeof_fmt(max_mem)))
        body.append('    "error": {}'.format('None' if err is None else
                                             json.dumps(err)))
        if self._dep_files_chksum is not None or\
                self._dep_hdf_chksum is not None:
            self._write_result_depends(body)

        if self._out_hdf_chksum is not None:  # could be multiple outputs
            coutput = '        "hdf": {}'.format(self._out_hdf_chksum)
            body.append('    "output": {{\n{}\n    }}'.format(coutput))

        if len(body) > 0: