當前位置: 首頁>>代碼示例>>Python>>正文


Python applications.Application類代碼示例

本文整理匯總了Python中zim.applications.Application的典型用法代碼示例。如果您正苦於以下問題:Python Application類的具體用法?Python Application怎麽用?Python Application使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Application類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: generate_image

	def generate_image(self, text):

		plotscriptfile = self.plotscriptfile
		pngfile = File(plotscriptfile.path[:-4] + '.png')

		plot_script = "".join(text)

		template_vars = { # they go in the template
			'gnuplot_script': plot_script,
			'png_fname': pngfile.path,
		}
		if self.attachment_folder and self.attachment_folder.exists():
			template_vars['attachment_folder'] = self.attachment_folder.path
		else:
			template_vars['attachment_folder'] = ''

		# Write to tmp file using the template for the header / footer
		lines = []
		self.template.process(lines, template_vars)
		plotscriptfile.writelines(lines)
		#~ print '>>>\n%s<<<' % plotscriptfile.read()

		# Call Gnuplot
		try:
			gnu_gp = Application(gnuplot_cmd)
			gnu_gp.run(args=( plotscriptfile.basename, ), cwd=plotscriptfile.dir)
							# you call it as % gnuplot output.plt

		except ApplicationError:
			return None, None # Sorry - no log
		else:
			return pngfile, None
開發者ID:fabricehong,項目名稱:zim-desktop,代碼行數:32,代碼來源:gnuplot_ploteditor.py

示例2: do_response_ok

	def do_response_ok(self):
		tmpfile = TmpFile('insert-screenshot.png')
		options = ()

		if COMMAND == 'scrot':
			if self.select_radio.get_active():
				options += ('--select', '--border')
				# Interactively select a window or rectangle with the mouse.
				# When selecting a window, grab wm border too
			else:
				options += ('--multidisp',)
				# For multiple heads, grab shot from each and join them together.

		delay = self.time_spin.get_value_as_int()
		if delay > 0:
			options += ('-d', str(delay))
			# Wait NUM seconds before taking a shot.

		helper = Application((COMMAND,) + options)

		def callback(status, tmpfile):
			if status == helper.STATUS_OK:
				name = time.strftime('screenshot_%Y-%m-%d-%H%M%S.png')
				dir = self.notebook.get_attachments_dir(self.page)
				file = dir.new_file(name)
				tmpfile.rename(file)
				self.ui.pageview.insert_image(file, interactive=False) # XXX ui == window
			else:
				ErrorDialog(self.ui,
					_('Some error occurred while running "%s"') % COMMAND).run()
					# T: Error message in "insert screenshot" dialog, %s will be replaced by application name

		tmpfile.dir.touch()
		helper.spawn((tmpfile,), callback, tmpfile)
		return True
開發者ID:gdw2,項目名稱:zim,代碼行數:35,代碼來源:screenshot.py

示例3: generate_image

    def generate_image(self, text):
        if isinstance(text, basestring):
            text = text.splitlines(True)

        plotscriptfile = self.plotscriptfile
        pngfile = File(plotscriptfile.path[:-2] + '.png')

        plot_script = "".join(text)

        template_vars = {
            'gnu_r_plot_script': plot_script,
            'png_fname': pngfile.path.replace('\\', '/'),
                # Even on windows, GNU R expects unix path seperator
        }

        # Write to tmp file usign the template for the header / footer
        plotscriptfile.writelines(
            self.template.process(template_vars)
        )
        #print '>>>%s<<<' % plotscriptfile.read()

        # Call GNU R
        try:
            gnu_r = Application(gnu_r_cmd)
            #~ gnu_r.run(args=('-f', plotscriptfile.basename, ), cwd=plotscriptfile.dir)
            gnu_r.run(args=('-f', plotscriptfile.basename, '--vanilla'), cwd=plotscriptfile.dir)
        except:
            return None, None # Sorry, no log
        else:
            return pngfile, None
開發者ID:DarioGT,項目名稱:Zim-QDA,代碼行數:30,代碼來源:gnu_r_ploteditor.py

示例4: run

 def run(self, args):
     self._tmpfile = None
     Application.run(self, args)
     if self._tmpfile:
         notebook, page, pageview = args
         page.parse('wiki', self._tmpfile.readlines())
         self._tmpfile = None
開發者ID:DarioGT,項目名稱:Zim-QDA,代碼行數:7,代碼來源:applications.py

示例5: _get_lilypond_version

def _get_lilypond_version():
	try:
		lilypond = Application(lilypondver_cmd)
		output = lilypond.pipe()
		return output[0].split()[2]
	except ApplicationError:
		return '2.14.2'
開發者ID:gdw2,項目名稱:zim,代碼行數:7,代碼來源:scoreeditor.py

示例6: generate_image

	def generate_image(self, text):
		if isinstance(text, basestring):
			text = text.splitlines(True)

		# Write to tmp file
		self.dotfile.writelines(text)

		# Call GraphViz
		dot = Application(dotcmd)
		dot.run((self.pngfile, self.dotfile))

		return self.pngfile, None
開發者ID:damiansimanuk,項目名稱:texslide,代碼行數:12,代碼來源:diagrameditor.py

示例7: generate_image

	def generate_image(self, text):
		# Write to tmp file
		self.diagfile.write(text)

		# Call seqdiag
		try:
			diag = Application(diagcmd)
			diag.run((self.pngfile, self.diagfile))
		except ApplicationError:
			return None, None # Sorry, no log
		else:
			return self.pngfile, None
開發者ID:hjq300,項目名稱:zim-wiki,代碼行數:12,代碼來源:sequencediagrameditor.py

示例8: __init__

    def __init__(self, binary_path, src_file, ui):
        """
        :type binary_path: str
        :type src_file: File
        :type ui: GtkInterface
        """

        Application.__init__(self, binary_path)

        self.ui = ui
        self.src_file = src_file
        self.dest_file = self.get_dest_file()
開發者ID:phoenixrvd,項目名稱:zim-plugin-dia,代碼行數:12,代碼來源:__init__.py

示例9: generate_image

    def generate_image(self, text):
        # Write to tmp file
        self.dotfile.write(text)

        # Call GraphViz
        try:
            dot = Application(dotcmd)
            dot.run(("-o", self.pngfile, self.dotfile))
        except ApplicationError:
            return None, None  # Sorry, no log
        else:
            return self.pngfile, None
開發者ID:dstuxo,項目名稱:zim-plugins,代碼行數:12,代碼來源:shaape.py

示例10: export

	def export(self):
		dir = Dir(self.create_tmp_dir('source_files'))
		init_notebook(dir)
		notebook = Notebook(dir=dir)
		for name, text in tests.WikiTestData:
			page = notebook.get_page(Path(name))
			page.parse('wiki', text)
			notebook.store_page(page)
		file = dir.file('Test/foo.txt')
		self.assertTrue(file.exists())

		zim = Application(('./zim.py', '--export', '--template=Default', dir.path, '--output', self.dir.path, '--index-page', 'index'))
		zim.run()
開發者ID:Jam71,項目名稱:Zim-QDA,代碼行數:13,代碼來源:export.py

示例11: get_fallback_emailclient

    def get_fallback_emailclient(klass):
        # Don't use mimetype lookup here, this is a fallback
        if os.name == 'nt':
            return StartFile()
        elif os.name == 'darwin':
            app = Application('open')
        else: # linux and friends
            app = Application('xdg-email')

        if app.tryexec():
            return app
        else:
            return WebBrowser()
開發者ID:DarioGT,項目名稱:Zim-QDA,代碼行數:13,代碼來源:applications.py

示例12: get_fallback_filebrowser

    def get_fallback_filebrowser(klass):
        # Don't use mimetype lookup here, this is a fallback
        # should handle all file types
        if os.name == 'nt':
            return StartFile()
        elif os.name == 'darwin':
            app = Application('open')
        else: # linux and friends
            app = Application('xdg-open')

        if app.tryexec():
            return app
        else:
            return WebBrowser()
開發者ID:DarioGT,項目名稱:Zim-QDA,代碼行數:14,代碼來源:applications.py

示例13: generate_image

    def generate_image(self, text):
        if isinstance(text, basestring):
            text = text.splitlines(True)

        # Write to tmp file
        self.dotfile.writelines(text)

        # Call GraphViz
        try:
            dot = Application(dotcmd)
            dot.run((self.pngfile, self.dotfile))
        except ApplicationError:
            return None, None # Sorry, no log
        else:
            return self.pngfile, None
開發者ID:DarioGT,項目名稱:Zim-QDA,代碼行數:15,代碼來源:diagrameditor.py

示例14: generate_image

	def generate_image(self, text):
		# Write to tmp file
		self.dotfile.write(text)

		# Call GraphViz
		try:
			dot = Application(dotcmd)
			dot.run((self.pngfile, self.dotfile))
		except ApplicationError:
			return None, None # Sorry, no log
		else:
			if self.pngfile.exists():
				return self.pngfile, None
			else:
				# When supplying a dot file with a syntax error, the dot command
				# doesn't return an error code (so we don't raise
				# ApplicationError), but we still don't have a png file to
				# return, so return None.
				return None, None
開發者ID:hjq300,項目名稱:zim-wiki,代碼行數:19,代碼來源:diagrameditor.py

示例15: insert_screenshot2

	def insert_screenshot2(self):
		self.notebook = self.window.ui.notebook  # XXX
		self.page = self.window.ui.page  # XXX
		self.ui = self.window.ui  # XXX
		tmpfile = TmpFile('insert-screenshot.png')
		delay = 0
		selection_mode = True

		helper = Application((self.screenshot_command,))

		def callback(status, tmpfile):
			name = time.strftime('screenshot_%Y-%m-%d-%H%M%S.png')
			imgdir = self.notebook.get_attachments_dir(self.page)
			imgfile = imgdir.new_file(name)
			tmpfile.rename(imgfile)
			pageview = self.ui.mainwindow.pageview
			pageview.insert_image(imgfile, interactive=False, force=True)

		tmpfile.dir.touch()
		helper.spawn((tmpfile,), callback, tmpfile)
開發者ID:blue119,項目名稱:yp-zim-plugin,代碼行數:20,代碼來源:screenshot2.py


注:本文中的zim.applications.Application類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。