/usr/share/medit-1/python/medit/runpython.py is in medit 1.0.3-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | #
# medit/runpython.py
#
# Copyright (C) 2004-2010 by Yevgen Muntyan <emuntyan@users.sourceforge.net>
#
# This file is part of medit. medit is free software; you can
# redistribute it and/or modify it under the terms of the
# GNU Lesser General Public License as published by the
# Free Software Foundation; either version 2.1 of the License,
# or (at your option) any later version.
#
# You should have received a copy of the GNU Lesser General Public
# License along with medit. If not, see <http://www.gnu.org/licenses/>.
#
import sys
import os
import re
import gtk
import moo
from moo import _
if os.name == 'nt':
PYTHON_COMMAND = '"' + sys.exec_prefix + '\\pythonw.exe" -u'
else:
PYTHON_COMMAND = 'python -u'
PANE_ID = 'PythonOutput'
class Runner(object):
def __init__(self, window, python_command=PYTHON_COMMAND, pane_id=PANE_ID, pane_label=None):
self.window = window
self.python_command = python_command
self.pane_id = pane_id
self.pane_label = pane_label
def __get_output(self):
return self.window.get_pane(self.pane_id)
def __ensure_output(self):
pane = self.__get_output()
if pane is None:
label = self.pane_label or moo.PaneLabel(icon_name=moo.STOCK_EXECUTE,
label_text=_("Python Output"))
output = moo.CmdView()
output.set_property("highlight-current-line", True)
output.set_filter(moo.command_filter_create("python"))
pane = gtk.ScrolledWindow()
pane.set_shadow_type(gtk.SHADOW_ETCHED_IN)
pane.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)
pane.add(output)
pane.show_all()
pane.output = output
self.window.add_pane(self.pane_id, pane, label, moo.PANE_POS_BOTTOM)
self.window.add_stop_client(output)
return pane
def run(self, filename=None, args_string=None, working_dir=None):
pane = self.__get_output()
if pane is not None and pane.output.running():
return
if filename is None:
doc = self.window.get_active_doc()
if not doc:
return
if not doc.get_filename() or doc.get_status() & moo.EDIT_MODIFIED:
if not doc.save():
return
filename = doc.get_filename()
pane = self.__ensure_output()
pane.output.clear()
self.window.paned.present_pane(pane)
if working_dir is None:
working_dir = os.path.dirname(filename)
cmd_line = self.python_command + ' "%s"' % os.path.basename(filename)
if args_string is not None:
cmd_line += ' %s' % (args_string,)
pane.output.run_command(cmd_line, working_dir)
|