Exemple #1
0
 def ExecuteFileInScope(self, filename, moduleEO):
     try:
         f = StreamReader(filename)
         runtime.DynamicObjectHelpers.SetMember(moduleEO, "__file__",
                                                Path.GetFullPath(filename))
         ASTs = parser.ParseFile(f)
         self.dbgASTs = ASTs
         scope = etgen.AnalysisScope(
             None,  #parent
             filename,
             self,
             Exprs.Expression.Parameter(Sympl, "symplRuntime"),
             Exprs.Expression.Parameter(ExpandoObject, "fileModule"))
         self.dbgascope = scope
         body = []
         self.dbgbody = body
         for e in ASTs:
             body.append(etgen.AnalyzeExpr(e, scope))
         ## Use ftype with void return so that lambda ignores body result.
         ftype = Exprs.Expression.GetActionType(
             System.Array[System.Type]([Sympl, ExpandoObject]))
         ## Due to .NET 4.0 co/contra-variance, IPy's binding isn't picking
         ## the overload with just IEnumerable<Expr>, so pick it explicitly.
         body = Exprs.Expression.Block.Overloads[IEnumerable[
             Exprs.Expression]](body)
         modulefun = Exprs.Expression.Lambda(ftype, body, scope.RuntimeExpr,
                                             scope.ModuleExpr)
         dbgmodfun = modulefun
         modulefun.Compile()(self, moduleEO)
     finally:
         f.Close()
Exemple #2
0
def GetNewFilePath(fileName, subDir="./"):
    path = Path.Combine(GetOutputDir(), subDir)
    if (not Directory.Exists(path)):
        Directory.CreateDirectory(path)
    path = Path.Combine(path, fileName)
    path = Path.GetFullPath(path)
    if (File.Exists(path)):
        File.Delete(path)
    True (not File.Exists(path), "Verify file does not exist: " + path)
    return path
Exemple #3
0
def GetResourceFilePath(relativeFilePath):
    #current directory is something like:
    #LevelEditor\bin\Debug.vs2010
    #Data directory is:
    #LevelEditor\Data
    
    #so the relative path to the data directory is:
    dataDir = Path.Combine(Environment.CurrentDirectory, "../../Data")
    resourcePath = Path.Combine(dataDir, relativeFilePath)
    resourcePath = Path.GetFullPath(resourcePath)
    
    return resourcePath
Exemple #4
0
    def __init__(self):

        self.settingsJsonPath = Path.GetFullPath('settings.json').replace(
            '\\', '/')

        self.InitializeComponent()

        self.config = {
            'Root': ['C:'],
            'Ignore': [],
            'IgnoreHidden': True,
            'MaxFile': 20,
            'MaxFolder': 30,
            'Window': {
                'Left': 100,
                'Top': 100,
                'Width': 800,
                'Height': 600
            },
            'Cmd': 'C:/Windows/System32/cmd.exe'
        }

        try:
            self.config.update(LoadJson(self.settingsJsonPath))
        except:
            log_except(sys.exc_info())

            if File.Exists(self.settingsJsonPath):
                File.Copy(self.settingsJsonPath,
                          self.settingsJsonPath + '.bak', True)
                MessageBox.Show(
                    self.settingsJsonPath + ' の読み込みに失敗したため\n' +
                    self.settingsJsonPath + '.bak としてバックアップを取り、新規作成しました。',
                    'Error', MessageBoxButtons.OK, MessageBoxIcon.Exclamation)

        rootList = self.config['Root']
        self.config['Root'] = ArrayList()
        self.config['Ignore'] = ArrayList(self.config['Ignore'])

        for i in rootList:
            self.AddRoot(i)

        for i in range(len(self.config['Ignore'])):
            self.config['Ignore'][i] = CorrectPath(self.config['Ignore'][i])

        SaveJson(self.settingsJsonPath, self.config)
Exemple #5
0
        self.obj = obj
        self.proxyType = proxyType

    def __getattribute__(self, attr):
        proxyType = object.__getattribute__(self, 'proxyType')
        obj = object.__getattribute__(self, 'obj')
        return getattr(proxyType, attr).__get__(obj, proxyType)


# Import the edm control software assemblies into IronPython

#sys.path.append(Path.GetFullPath("C:\\Control Programs\\EDMSuite\\ScanMaster\\bin\\Decelerator\\"))
#clr.AddReferenceToFile("ScanMaster.exe")

sys.path.append(
    Path.GetFullPath("C:\\ControlPrograms\\EDMSuite\\MOTMaster\\bin\\CaF\\"))
clr.AddReferenceToFile("MOTMaster.exe")

sys.path.append(
    Path.GetFullPath(
        "C:\\ControlPrograms\\EDMSuite\\MoleculeMOTHardwareControl\\bin\\CaF\\"
    ))
clr.AddReferenceToFile("MoleculeMOTHardwareControl.exe")
clr.AddReferenceToFile("DAQ.dll")
clr.AddReferenceToFile("SharedCode.dll")

# Load some system assemblies that we'll need
clr.AddReference("System.Drawing")
clr.AddReference("System.Windows.Forms")
clr.AddReference("System.Xml")
Exemple #6
0
# edm_init.py - sets up the IronPython environment ready for scripting
# the edm control software.

import clr
import sys
from System.IO import Path

# Import the edm control software assemblies into IronPython
sys.path.append(Path.GetFullPath("..\\EDMHardwareControl\\bin\\EDM\\"))
clr.AddReferenceToFile("EDMHardwareControl.exe")
clr.AddReferenceToFile("DAQ.dll")

# Load some system assemblies that we'll need
clr.AddReference("System.Drawing")
clr.AddReference("System.Windows.Forms")
clr.AddReference("System.Xml")


# code for IronPython remoting problem workaround
class typedproxy(object):
    __slots__ = ['obj', 'proxyType']

    def __init__(self, obj, proxyType):
        self.obj = obj
        self.proxyType = proxyType

    def __getattribute__(self, attr):
        proxyType = object.__getattribute__(self, 'proxyType')
        obj = object.__getattribute__(self, 'obj')
        return getattr(proxyType, attr).__get__(obj, proxyType)
Exemple #7
0
from System.IO import FileSystemWatcher, Path
from System.Threading import Thread

from UdpSender import UdpSender, port, group

directory = Path.GetDirectoryName(Path.GetFullPath(__file__))
dataFile = 'data.txt'

watcher = FileSystemWatcher()
watcher.Path = directory
watcher.Filter = dataFile

sender = UdpSender(port, group)


def onChanged(source, event):
    print 'Changed:', event.ChangeType, event.FullPath
    sender.send('DATA:FILE:CHANGED')


watcher.Changed += onChanged

watcher.EnableRaisingEvents = True

while True:
    Thread.Sleep(1000)
Exemple #8
0
# sc_init.py - sets up the IronPython environment ready for scripting
# the sympathetic control software.

import clr
import sys
from System.IO import Path
import time

# Import the edm control software assemblies into IronPython

#sys.path.append(Path.GetFullPath("C:\\Control Programs\\EDMSuite\\ScanMaster\\bin\\Decelerator\\"))
#clr.AddReferenceToFile("ScanMaster.exe")

sys.path.append(
    Path.GetFullPath(
        "C:\\Control Programs\\EDMSuite\\MOTMaster\\bin\\Decelerator\\"))
clr.AddReferenceToFile("MOTMaster.exe")

sys.path.append(
    Path.GetFullPath(
        "C:\\Control Programs\\EDMSuite\\DecelerationHardwareControl\\bin\\Decelerator\\"
    ))
clr.AddReferenceToFile("MoleculeMOTHardwareControl.exe")
clr.AddReferenceToFile("DAQ.dll")
clr.AddReferenceToFile("SharedCode.dll")

# Load some system assemblies that we'll need
clr.AddReference("System.Drawing")
clr.AddReference("System.Windows.Forms")
clr.AddReference("System.Xml")
# deceleration_init.py - sets up the IronPython environment ready for scripting
# the deceleration control software.

import clr
import sys
from System.IO import Path

# Import the edm control software assemblies into IronPython
sys.path.append(Path.GetFullPath("..\\ScanMaster\\bin\\Debug\\"))
clr.AddReferenceToFile("ScanMaster.exe")
sys.path.append(
    Path.GetFullPath("..\\DecelerationHardwareControl\\bin\\Debug\\"))
clr.AddReferenceToFile("DecelerationHardwareControl.exe")
clr.AddReferenceToFile("DAQ.dll")
clr.AddReferenceToFile("SharedCode.dll")

# Load some system assemblies that we'll need
clr.AddReference("System.Drawing")
clr.AddReference("System.Windows.Forms")
clr.AddReference("System.Xml")


# code for IronPython remoting problem workaround
class typedproxy(object):
    __slots__ = ['obj', 'proxyType']

    def __init__(self, obj, proxyType):
        self.obj = obj
        self.proxyType = proxyType

    def __getattribute__(self, attr):
Exemple #10
0
    server = BaseHTTPServer.HTTPServer(('127.0.0.1', 0), RequestHandler)
    webbrowser.open('http://127.0.0.1:%s' % server.server_port)
    server.handle_request()


sw = Stopwatch.StartNew()
plugin = TESVSnip.Domain.Model.Plugin(gameDir + 'asdf.esp')
rec = None
# for rec in plugin.Records:
# if isinstance(rec, GroupRecord):
# break
for kvp in plugin.EnumerateRecords('RACE'):
    rec = kvp.Value
    #break
cssfile = Path.GetFullPath(
    Path.Combine(Path.GetDirectoryName(sys.argv[0]),
                 '../scripts/renderer.css'))
html = renderer.HTMLRenderer(title="Record", css=(cssfile, ))
html.GetHeader(rec)
#html.GetHeader(plugin)
html.page.hr()
html.GetDescription(rec)

strpage = str(html)
with open('test4.html', "w") as f:
    f.write(strpage)
#print strpage
#browser( strpage )

sw.Stop()
t = TimeSpan.FromMilliseconds(sw.ElapsedMilliseconds)
deep = IN[2]

# instantiate error log
error_log = None

files = []
try:
    # determine if deepsearch from current directory is needed
    if deep:
        docs = Directory.GetFiles(folders, search, SearchOption.AllDirectories)
    else:
        docs = Directory.GetFiles(folders, search)

    # get only docs that are not read-only and hidden (and thereby system etc.)
    ro = FileAttributes.ReadOnly
    hi = FileAttributes.Hidden

    for doc in docs:
        if File.GetAttributes(doc).HasFlag(ro) == 0:
            if File.GetAttributes(doc).HasFlag(hi) == 0:
                files.append(Path.GetFullPath(doc))
        else:
            error_log = 'File(s) are read only, correct input!'
except BaseException:
    error_log = 'Directory does not exist, correct input!'

# return assigned the OUT port
if error_log:
    files = error_log
OUT = files
Exemple #12
0
 def _get_file(self, filename):
     filename = Path.GetFullPath(filename)
     if not filename in self.source_files:
         self.source_files[filename] = File.ReadAllLines(filename)
     return self.source_files[filename]
Exemple #13
0
# sc_init.py - sets up the IronPython environment ready for scripting
# the sympathetic control software.

import clr
import sys
from System.IO import Path

# Import the edm control software assemblies into IronPython

sys.path.append(Path.GetFullPath("..\\ScanMaster\\bin\\Sympathetic\\"))
clr.AddReferenceToFile("ScanMaster.exe")

sys.path.append(Path.GetFullPath("..\\MOTMaster\\bin\\Sympathetic\\"))
clr.AddReferenceToFile("MOTMaster.exe")

sys.path.append(
    Path.GetFullPath("..\\SympatheticHardwareControl\\bin\\Sympathetic\\"))
clr.AddReferenceToFile("SympatheticHardwareControl.exe")
clr.AddReferenceToFile("DAQ.dll")
clr.AddReferenceToFile("SharedCode.dll")

# Load some system assemblies that we'll need
clr.AddReference("System.Drawing")
clr.AddReference("System.Windows.Forms")
clr.AddReference("System.Xml")


# code for IronPython remoting problem workaround
class typedproxy(object):
    __slots__ = ['obj', 'proxyType']
Exemple #14
0
# edm_init.py - sets up the IronPython environment ready for scripting
# the edm control software.

import clr
import sys
from System.IO import Path

# Import the edm control software assemblies into IronPython
sys.path.append(Path.GetFullPath("..\\ScanMaster\\bin\\EDM\\"))
clr.AddReferenceToFile("ScanMaster.exe")
sys.path.append(Path.GetFullPath("..\\EDMBlockHead\\bin\\EDM\\"))
clr.AddReferenceToFile("EDMBlockHead.exe")
sys.path.append(Path.GetFullPath("..\\EDMHardwareControl\\bin\\EDM\\"))
clr.AddReferenceToFile("EDMHardwareControl.exe")
clr.AddReferenceToFile("DAQ.dll")
clr.AddReferenceToFile("SharedCode.dll")
sys.path.append(Path.GetFullPath("..\\SirCachealot\\bin\\EDM\\"))
clr.AddReferenceToFile("SirCachealot.exe")
sys.path.append(Path.GetFullPath("..\\TransferCavityLock2012\\bin\\EDM\\"))
clr.AddReferenceToFile("TransferCavityLock.exe")
sys.path.append(Path.GetFullPath("..\\EDMPhaseLock\\bin\\EDM\\"))
clr.AddReferenceToFile("EDMPhaseLock.exe")

# Load some system assemblies that we'll need
clr.AddReference("System.Drawing")
clr.AddReference("System.Windows.Forms")
clr.AddReference("System.Xml")


# code for IronPython remoting problem workaround
class typedproxy(object):
Exemple #15
0
# sm_init.py - sets up the IronPython environment ready for scripting
# scan master.

import clr
import sys
from System.IO import Path

# Import the edm control software assemblies into IronPython
sys.path.append(Path.GetFullPath("..\\ScanMaster\\bin\\EDM\\"))
clr.AddReferenceToFile("ScanMaster.exe")
sys.path.append(Path.GetFullPath("..\\EDMBlockHead\\bin\\EDM\\"))
clr.AddReferenceToFile("EDMBlockHead.exe")
sys.path.append(Path.GetFullPath("..\\EDMHardwareControl\\bin\\EDM\\"))
clr.AddReferenceToFile("EDMHardwareControl.exe")
clr.AddReferenceToFile("DAQ.dll")
clr.AddReferenceToFile("SharedCode.dll")
sys.path.append(Path.GetFullPath("..\\SirCachealot\\bin\\EDM\\"))
clr.AddReferenceToFile("SirCachealot.exe")

# Load some system assemblies that we'll need
clr.AddReference("System.Drawing")
clr.AddReference("System.Windows.Forms")
clr.AddReference("System.Xml")


# code for IronPython remoting problem workaround
class typedproxy(object):
    __slots__ = ['obj', 'proxyType']

    def __init__(self, obj, proxyType):
        self.obj = obj
Exemple #16
0
def GetFullPath(path):
    return Path.GetFullPath(path)
Exemple #17
0
# sc_init.py - sets up the IronPython environment ready for scripting
# the sympathetic control software.

import clr
import sys
from System.IO import Path
import time

# Import the edm control software assemblies into IronPython

#sys.path.append(Path.GetFullPath("C:\\ExperimentControl\\EDMSuite\\ScanMaster\\bin\\Sympathetic\\"))
#clr.AddReferenceToFile("ScanMaster.exe")

sys.path.append(
    Path.GetFullPath(
        "C:\\ExperimentControl\\EDMSuite\\MOTMaster\\bin\\Sympathetic\\"))
clr.AddReferenceToFile("MOTMaster.exe")

sys.path.append(
    Path.GetFullPath(
        "C:\\ExperimentControl\\EDMSuite\\SympatheticHardwareControl\\bin\\Sympathetic\\"
    ))
clr.AddReferenceToFile("SympatheticHardwareControl.exe")
clr.AddReferenceToFile("DAQ.dll")
clr.AddReferenceToFile("SharedCode.dll")

# Load some system assemblies that we'll need
clr.AddReference("System.Drawing")
clr.AddReference("System.Windows.Forms")
clr.AddReference("System.Xml")