예제 #1
0
파일: mainmenu.py 프로젝트: song2001/OOF2
    ellipsis=1,
    accel='l',
    help="Execute a Python script.",
    discussion=xmlmenudump.loadFile('DISCUSSIONS/common/menu/loadscript.xml')
    ))

_startupmenu.addItem(OOFMenuItem(
    'Script',
    callback=loadscript,
    params=[filenameparam.ReadFileNameParameter('filename', 'logfile',
                                                tip="Name of the file.",
                                                ident="load")],
    no_log=1,
    ellipsis=1,
    accel='l',
    disabled=config.nanoHUB(),  # loading arbitrary scripts is a
                                # security hole on nanoHUB
    help="Execute a Python script.",
    discussion=xmlmenudump.loadFile('DISCUSSIONS/common/menu/loadscript.xml')
    ))

# "Data" files are distinguished from scripts in that they're not read
# by the Python interpreter directly, and therefore can't contain
# arbitrary Python code.  They can only contain menu commands from the
# OOF.LoadData menu.  The command arguments can be constants or
# variables and functions that are defined in the main OOF namespace,
# or lists and tuples thereof.

def loaddata(menuitem, filename):
    if filename is not None:
        from ooflib.common.IO import datafile
예제 #2
0
from ooflib.common.IO import menuparser
from ooflib.common.IO import oofmenu
from ooflib.common.IO import parameter
import os.path
import string
import types

##############################

datafileversion = 1.0

##############################

# Data file formats

if not config.nanoHUB():

    class DataFileFormat(
            enum.EnumClass((
                'script',
                'A fully functioning Python script.  Flexible and editable, but insecure.'
            ), (
                'ascii',
                'An ASCII file with Python-like syntax that will NOT be parsed by the Python interpreter.  Inflexible, editable, but secure.'
            ), ('binary',
                'A binary file. Inflexible and uneditable, but secure, compact and not subject to round-off error.'
                ))):
        tip = "Types of &oof2; data files."
        discussion = "<para>See <xref linkend='Section:Concepts:FileFormats'/>.</para>"

else:  # in nanoHUB mode scripts aren't allowed
예제 #3
0
파일: datafile.py 프로젝트: anilkunwar/OOF2
from ooflib.common.IO import menuparser
from ooflib.common.IO import oofmenu
from ooflib.common.IO import parameter
import os.path
import string
import types

##############################

datafileversion = 1.0

##############################

# Data file formats

if not config.nanoHUB():
    class DataFileFormat(enum.EnumClass(
        ('script',
 'A fully functioning Python script.  Flexible and editable, but insecure.'),
        ('ascii', 'An ASCII file with Python-like syntax that will NOT be parsed by the Python interpreter.  Inflexible, editable, but secure.'),
        ('binary', 'A binary file. Inflexible and uneditable, but secure, compact and not subject to round-off error.')
        )):
        tip = "Types of &oof2; data files."
        discussion = "<para>See <xref linkend='Section-Concepts-FileFormats'/>.</para>"

else:                           # in nanoHUB mode scripts aren't allowed
    class DataFileFormat(enum.EnumClass(
        ('ascii', 'An ASCII file with Python-like syntax that will NOT be parsed by the Python interpreter.  Inflexible, editable, but secure.'),
        ('binary', 'A binary file. Inflexible and uneditable, but secure, compact and not subject to round-off error.')
        )):
        tip = "Types of &oof2; data files."