/usr/lib/python2.7/dist-packages/sagenb/interfaces/worksheet_process.py is in python-sagenb 0.13+ds1-2.
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 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | # -*- coding: utf-8 -*
"""
Worksheet process base clase
AUTHORS:
- William Stein
"""
#############################################################################
#
# Copyright (C) 2009 William Stein <wstein@gmail.com>
# Distributed under the terms of the GNU General Public License (GPL)
# The full text of the GPL is available at:
# http://www.gnu.org/licenses/
#
#############################################################################
###################################################################
# Abstract base class
###################################################################
class WorksheetProcess:
"""
A controlled Python process that executes code. This is a
reference implementation.
"""
def __init__(self, **kwds):
"""
Initialize this worksheet process.
"""
raise NotImplementedError
def __repr__(self):
"""
Return string representation of this worksheet process.
"""
return "Worksheet process"
def __getstate__(self):
"""
Used for pickling. We return an empty state otherwise
this could not be pickled.
"""
return {}
###########################################################
# Control the state of the subprocess
###########################################################
def interrupt(self):
"""
Send an interrupt signal to the currently running computation
in the controlled process. This may or may not succeed. Call
``self.is_computing()`` to find out if it did.
"""
raise NotImplementedError
def quit(self):
"""
Quit this worksheet process.
"""
raise NotImplementedError
def start(self):
"""
Start this worksheet process running.
"""
raise NotImplementedError
def update(self):
"""
Update this worksheet process
"""
# default implementation is to do nothing.
###########################################################
# Query the state of the subprocess
###########################################################
def is_computing(self):
"""
Return True if a computation is currently running in this worksheet subprocess.
OUTPUT:
- ``bool``
"""
raise NotImplementedError
def is_started(self):
"""
Return true if this worksheet subprocess has already been started.
OUTPUT:
- ``bool``
"""
raise NotImplementedError
###########################################################
# Sending a string to be executed in the subprocess
###########################################################
def execute(self, string, data=None):
"""
Start executing the given string in this subprocess.
INPUT:
- ``string`` -- a string containing code to be executed.
- ``data`` -- a string or None; if given, must specify an
absolute path on the server host filesystem. This may
be ignored by some worksheet process implementations.
"""
raise NotImplementedError
###########################################################
# Getting the output so far from a subprocess
###########################################################
def output_status(self):
"""
Return OutputStatus object, which includes output from the
subprocess from the last executed command up until now,
information about files that were created, and whether
computing is now done.
OUTPUT:
- ``OutputStatus`` object.
"""
raise NotImplementedError
|