def setUp(self): self.OLD_SERVER_ADDRESS = zim.ipc.SERVER_ADDRESS self.OLD_AUTHKEY_FILE = zim.ipc.AUTHKEY_FILE zim.ipc.SERVER_ADDRESS += '-test-%i' % os.getpid() zim.ipc.AUTHKEY_FILE = get_tmpdir().file('zim-server-authkey-test-%i' % os.getpid()) zim.ZIM_EXECUTABLE = './zim.py'
def export_iter(self, pages): basename = encode_filename(pages.name) dir = get_tmpdir().subdir('mhtml_export_tmp_dir') dir.remove_children() file = dir.file(basename + '.html') layout = SingleFileLayout(file, pages.prefix) exporter = SingleFileExporter(layout, self.template, 'html', document_root_url=self.document_root_url) for p in exporter.export_iter(pages): yield p encoder = MHTMLEncoder() linker = ExportLinker(pages.notebook, layout, output=file, usebase=True) self.file.write(encoder(layout, linker))
# Run actual server object server = Server() server.start() server.main() logger.debug('Server process %i quit', os.getpid()) if sys.platform == 'win32': # Windows named pipe from zim.config import get_environ SERVER_ADDRESS = '\\\\.\\pipe\\zimServer-%s' % get_environ('USER') SERVER_ADDRESS_FAMILY = 'AF_PIPE' else: # Unix domain socket SERVER_ADDRESS = str(get_tmpdir().file('zim-server-socket').path) # BUG in multiprocess, name must be str instead of basestring SERVER_ADDRESS_FAMILY = 'AF_UNIX' AUTHKEY_FILE = get_tmpdir().file('zim-server-authkey') # Zim always initializes the tmpdir with mode 700, so should be private class Server(object): '''Main object in the server process, handling all communication''' _signals = ('notebook-list-changed') def __init__(self): self.listener = None
def testTmpFile(self): '''Test TmpFile object''' dir = get_tmpdir() file = TmpFile('foo.txt') self.assertTrue(file.ischild(dir))