Пример #1
0
def dllVsExe():
    '''
    Creates a DLL and EXE of the same namespace to see
    which one IP uses.
    '''
    #create the DLL C# file
    createAssembly("DLL", "DLLEXE", 1)
    #create the assembly
    compileAssembly(Directory.GetCurrentDirectory() + "\\fooDLL.cs")

    #create an EXE C# file
    file_name = Directory.GetCurrentDirectory() + "\\fooEXE.cs"
    file = open(file_name, "w")
    print >> file, cs_ipy % ("DLLEXE", 0)
    file.close()
    #create the exe
    compileExe(file_name)
Пример #2
0
 def open_project(self, filepath):
     directory = Directory.GetCurrentDirectory()
     fullpath = os.path.join(directory, filepath)
     if not os.path.exists(fullpath):
         fullpath = filepath
     APx = self.init_apx()
     APx.OpenProject(fullpath)
     return APx
Пример #3
0
def overrideNative():
    '''
    Tries to override the native IP sys module.
    '''
    #create the "sys" C# file
    file_name = Directory.GetCurrentDirectory() + "\\sys.cs"
    file = open(file_name, "w")
    print >> file, cs_native
    file.close()

    #compile the assembly
    compileAssembly(file_name)

    #create the "re" C# file
    file_name = Directory.GetCurrentDirectory() + "\\re.cs"
    file = open(file_name, "w")
    print >> file, cs_native_re
    file.close()

    #compile the assembly
    compileAssembly(file_name)
Пример #4
0
def exeOnly():
    '''
    Creates an EXE in it's own namespace.
    '''
    #create an EXE C# file
    file_name = Directory.GetCurrentDirectory() + "\\fooEXEONLY.cs"
    file = open(file_name, "w")
    print >> file, cs_ipy % ("EXEONLY", 100)
    file.close()

    #create the exe
    compileExe(file_name)
Пример #5
0
def createAssembly(file_id, namespace_id, bar_num, default_filename="foo"):
    '''
    Helper function creates a single "foo" assembly. Returns
    the file_name.
    '''
    #create the C# file
    file_name = Directory.GetCurrentDirectory(
    ) + "\\" + default_filename + str(file_id) + ".cs"
    file = open(file_name, "w")
    print >> file, cs_ipy % (str(namespace_id), bar_num)
    file.close()

    #create the assembly
    compileAssembly(file_name)
Пример #6
0
    def InitializePath(self):
        searchPath = []
        currentDir = Directory.GetCurrentDirectory()
        searchPath.append(currentDir)
        filePathDir = Path.GetDirectoryName(Path.Combine(currentDir, self.fileName))
        searchPath.append(filePathDir)
        entryDir = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)
        searchPath.append(entryDir)
        siteDir = Path.Combine(entryDir, "Lib")
        searchPath.append(siteDir)
        dllsDir = Path.Combine(entryDir, "DLLs")
        if Directory.Exists(dllsDir):
            searchPath.append(dllsDir)

        self.engine.SetSearchPaths(Array[str](searchPath))
Пример #7
0
def textFiles():
    '''
    Creates *.txt files. One is actually a text file
    and the other is a DLL in disguise
    '''
    #create a fake DLL
    file_name = Directory.GetCurrentDirectory() + "\\fooGARBAGE.dll"
    file = open(file_name, "w")
    print >> file, garbage
    file.close()

    #create a real DLL and give it the *.txt extension
    createAssembly("TXTDLL", "TXTDLL", 7)

    File.Move("fooTXTDLL.dll", "fooTXTDLL.txt")
Пример #8
0
    def InitializePath(self):
        searchPath = []
        currentDir = Directory.GetCurrentDirectory()
        searchPath.append(currentDir)
        filePathDir = Path.GetDirectoryName(Path.Combine(currentDir, self.fileName))
        searchPath.append(filePathDir)
        entryDir = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)
        searchPath.append(entryDir)
        siteDir = Path.Combine(entryDir, "Lib")
        searchPath.append(siteDir)
        devStdLibDir = Path.Combine(entryDir, '../../External.LCA_RESTRICTED/Languages/IronPython/27/Lib')
        searchPath.append(devStdLibDir)
        dllsDir = Path.Combine(entryDir, "DLLs")
        if Directory.Exists(dllsDir):
            searchPath.append(dllsDir)

        self.engine.SetSearchPaths(Array[str](searchPath))
Пример #9
0
def run_interactive_main():
    #if the commandline was invoked so: ipy run_interactive.py test_x.py then run just that one test.
    testName = sys.argv[1] if len(sys.argv) > 1 else None
    
    if testName:
        testsToRun = Directory.GetFiles(Directory.GetCurrentDirectory() , testName)        
    else:
	    print "No test name provided"
	    sys.exit(-1)
	    
    allErrors = []
    for test in testsToRun:
        try:
            print "\nRunning test in interactive mode - ", test
            con = FileConsole(test)        
            con.Run()
        except Exception, e:
            print e, e.clsException
            allErrors.append((test, sys.exc_info()[0], sys.exc_info()[1]))
Пример #10
0
def ModulesToAssembly(modules,
                      name,
                      code="",
                      references=None,
                      outputDirectory=None,
                      inMemory=False):
    CompilerParams = Compiler.CompilerParameters()

    if outputDirectory is None:
        outputDirectory = Directory.GetCurrentDirectory()
    if not inMemory:
        CompilerParams.OutputAssembly = Path.Combine(outputDirectory,
                                                     name + ".dll")
        CompilerParams.GenerateInMemory = False
    else:
        CompilerParams.GenerateInMemory = True

    CompilerParams.TreatWarningsAsErrors = False
    CompilerParams.GenerateExecutable = False

    modulesListCompiler = ';'.join(map(str, modules))
    CompilerParams.CompilerOptions = "/addmodule:" + modulesListCompiler
    print(CompilerParams.CompilerOptions)

    for reference in references or []:
        CompilerParams.ReferencedAssemblies.Add(reference)

    provider = CSharpCodeProvider()
    compile = provider.CompileAssemblyFromSource(CompilerParams, code)

    if compile.Errors.HasErrors:
        for err in compile.Errors:
            print(err)
        raise Exception("Compile error(s)")

    if inMemory:
        return compile.CompiledAssembly
    return compile.PathToAssembly
Пример #11
0
    clr.AddReferenceToFile("sbs_library.dll")
    from SbsTest import C
    o = C()
    g1 = o.M1
    g2 = o.M2
    g3 = o.M3
    
    #for peverify runs
    from System.IO import Path, File, Directory
    if File.Exists(Path.Combine(Path.GetTempPath(), "sbs_library.dll")):
        try:
            File.Delete(Path.Combine(Path.GetTempPath(), "sbs_library.dll"))
        except:
            pass
    if not File.Exists(Path.Combine(Path.GetTempPath(), "sbs_library.dll")):
        File.Copy(Path.Combine(Directory.GetCurrentDirectory(), "sbs_library.dll"), Path.Combine(Path.GetTempPath(), "sbs_library.dll"))
    
else:
    g1 = f1
    g2 = f2
    g3 = f3

# combinations
choices = [(), (0,), (1,), (2,), (3,), (0, 1), (0, 2), (0, 3), (1, 2), (1, 3), (2, 3), (0, 1, 2), (0, 1, 3), (0, 2, 3), (1, 2, 3), (0, 1, 2, 3) ]

def to_str(l): return [str(x) for x in l] 

def replace_B(line):
    count = 0
    while True:
        pos = line.find("B")
Пример #12
0
    g1 = o.M1
    g2 = o.M2
    g3 = o.M3

    #for peverify runs
    if clr.IsNetStandard:
        clr.AddReference("System.IO.FileSystem")
    from System.IO import Path, File, Directory
    if File.Exists(Path.Combine(Path.GetTempPath(), "sbs_library.dll")):
        try:
            File.Delete(Path.Combine(Path.GetTempPath(), "sbs_library.dll"))
        except:
            pass
    if not File.Exists(Path.Combine(Path.GetTempPath(), "sbs_library.dll")):
        File.Copy(
            Path.Combine(Directory.GetCurrentDirectory(), "sbs_library.dll"),
            Path.Combine(Path.GetTempPath(), "sbs_library.dll"))

else:
    g1 = f1
    g2 = f2
    g3 = f3

# combinations
choices = [(), (0, ), (1, ), (2, ), (3, ), (0, 1), (0, 2), (0, 3), (1, 2),
           (1, 3), (2, 3), (0, 1, 2), (0, 1, 3), (0, 2, 3), (1, 2, 3),
           (0, 1, 2, 3)]


def to_str(l):
    return [str(x) for x in l]
# Variabili Sistema
import clr
clr.AddReference('System.Web.Extensions')
from System.Collections.Generic import List
from time import time
from System.Net import WebRequest
from System.IO import StreamReader, Directory, Path, File
from System.Web.Script.Serialization import JavaScriptSerializer

CONFIGS = {}
RESOURCES = None
config_path = Path.Combine(Directory.GetCurrentDirectory(), 'Scripts\\json\lnr_config.json')
res_path = Path.Combine(Directory.GetCurrentDirectory(), 'Scripts\\json\lnr_resources.json')

with open(config_path, 'r') as f:
    CONFIGS = JavaScriptSerializer.DeserializeObject(JavaScriptSerializer(), f.read())

## RESOURCES MANAGEMENT START
class ResourceEntry(object):

    def __init__(self, name='', graphic=0, color=0, value=0):
        self.name = name or ''
        self.graphic = graphic or 0
        self.color = color or 0
        self.value = value or 0

    def __iter__(self):
        for k,v in self.__dict__.iteritems():
            yield (k,v)

class Miner(object):
    Current = {'book' : 0, 'rune' : 0}
    Delay = {
        'dig' : 500,
        'drag' : 600,
        'cast' : 2000,
        'smelt' : 300,
        'recovery' : 2000,
        'timeout' : 4000
        }
    IDs = {
        'color' : {
            '0' : 'iron',
            '2419' : 'dull',
            '2406' : 'shadow',
            '2413' : 'copper',
            '2418', : 'bronze',
            '2213' : 'gold',
            '2425' : 'agapite',
            '2207' : 'verite',
            '2219' : 'valorite'  
            }
        'gem' : {
            'amber' : 0x0F25,
            'amethyst' : 0,
            'blackrock' : 0,
            'citrine' : 0x0F15,
            'diamond' : 0x0F26,
            'emerald' : 0x0F10,
            'ruby' : 0x0F13,
            'sapphire' : 0x0F19,
            'starsapphire' : 0x0F21,
            'turmaline' : 0
            }
        'ingot' : 0x1BF2,
        'ore' : [],
        'rock' : 0x1779,
        'sand' : 0,
        'shovel' : 0x0F3A,
        'tool' : 0x1EB8,
        'unique' : {
            'bluediamond' : 0x3198,
            'darksapphire' : 0x3192,
            'ecrucitrine' : 0x3195,
            'fireruby' : 0x3197,
            'perfectemerald' : 0x3194,
            'turquoise' : 0x3193,
            }
        }
    
    CounterPath = Directory.GetCurrentDirectory() + '\\Scripts\\json\Miner_Counter.json'
    OptPath = Directory.GetCurrentDirectory() + '\\Scripts\\json\Miner_Opt.json'

    Counters = None
    Opt = None
    Spots = []
    
    MineTiles = [
        220, 221, 222, 223, 224, 225, 226, 227, 228, 229,
        230, 231, 236, 237, 238, 239, 240, 241, 242, 243,
        244, 245, 246, 247, 252, 253, 254, 255, 256, 257,
        258, 259, 260, 261, 262, 263, 268, 269, 270, 271,
        272, 273, 274, 275, 276, 277, 278, 279, 286, 287,
        288, 289, 290, 291, 292, 293, 294, 296, 296, 297,
        321, 322, 323, 324, 467, 468, 469, 470, 471, 472,
        473, 474, 476, 477, 478, 479, 480, 481, 482, 483,
        484, 485, 486, 487, 492, 493, 494, 495, 543, 544,
        545, 546, 547, 548, 549, 550, 551, 552, 553, 554,
        555, 556, 557, 558, 559, 560, 561, 562, 563, 564,
        565, 566, 567, 568, 569, 570, 571, 572, 573, 574,
        575, 576, 577, 578, 579, 581, 582, 583, 584, 585,
        586, 587, 588, 589, 590, 591, 592, 593, 594, 595,
        596, 597, 598, 599, 600, 601, 610, 611, 612, 613,
        1010, 1741, 1742, 1743, 1744, 1745, 1746, 1747, 1748, 1749,
        1750, 1751, 1752, 1753, 1754, 1755, 1756, 1757, 1771, 1772,
        1773, 1774, 1775, 1776, 1777, 1778, 1779, 1780, 1781, 1782,
        1783, 1784, 1785, 1786, 1787, 1788, 1789, 1790, 1801, 1802,
        1803, 1804, 1805, 1806, 1807, 1808, 1809, 1811, 1812, 1813,
        1814, 1815, 1816, 1817, 1818, 1819, 1820, 1821, 1822, 1823,
        1824, 1831, 1832, 1833, 1834, 1835, 1836, 1837, 1838, 1839,
        1840, 1841, 1842, 1843, 1844, 1845, 1846, 1847, 1848, 1849,
        1850, 1851, 1852, 1853, 1854, 1861, 1862, 1863, 1864, 1865,
        1866, 1867, 1868, 1869, 1870, 1871, 1872, 1873, 1874, 1875,
        1876, 1877, 1878, 1879, 1880, 1881, 1882, 1883, 1884, 1981,
        1982, 1983, 1984, 1985, 1986, 1987, 1988, 1989, 1990, 1991,
        1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
        2002, 2003, 2004, 2028, 2029, 2030, 2031, 2032, 2033, 2100,
        2101, 2102, 2103, 2104, 2105,
        17723, 17724, 17725, 17726, 17727, 17728, 17729, 17730, 17731,
        17732, 17733, 17734, 17735, 17736, 17737, 17738, 17739, 17740,
        17741, 17742, 17743
        ]

    def __init__(self):
        json = open(self.CounterPath, 'r').read()
        self.Counters = JavaScriptSerializer().DeserializeObject(json)
        
        json = open(self.OptPath, 'r').read()
        self.Opt = JavaScriptSerializer().DeserializeObject(json)

    @property
    def IsOverWeight(self):
        return (Player.MaxWeight - Player.Weight < 30)

    @property
    def ImHome(self):
        return sum(abs(Player.Position.X - self.Opt['homepos']['x']), abs(Player.Position.Y - self.Home['y'])) / 2 > 10

    def SaveCount(self):
        open(self.CounterPath, 'w').write(JavaScriptSerializer().Serialize(self.Counters))
        
    def SaveSpots(self):
        if self.Spots != self.m_Spots:
            open(self.SpotPath, 'w').write(JavaScriptSerializer().Serialize(self.Spots))


    def Deposit(self):
        ores = [o for o in Player.Backpack.Contains if o.ItemID in self.IDs['ore']]
                        
        for ore in ores:
            Items.UseItem(ore)
            Target.WaitForTarget(self.Delay['timeout'])
            Target.TargetExecute(self.Opt['homeforge'])
            Misc.Pause(self.Delay['smelt'])

        ingots = [i for i in Player.Backpack.Contains if i.ItemID == self.IDs['ingot']]
        
        for ingot in ingots:
            mat = self.IDs['color'][str(ingot.Hue)]
            self.Counters['ingot'][mat] += ingot.Amount
            Items.Move(ingot, self.Opt['homechest']['ingot'], 0)
            Misc.Pause(self.Delay['drag'])

        gems = [g for g in Player.Backpack.Contains if str(g.ItemID) in self.IDs['gem'].keys()]
        
        for gem in gems:
            mat = self.IDs['gem'][str(gem.ItemID)]
            self.Counters['gem'][mat] += gem.Amount
            Items.Move(gem, self.Opt['homechest']['gem'], 0)
            Misc.Pause(self.Delay['drag'])

        uniques = [u for u in Player.Backpack.Contains if str(u.ItemID) in self.IDs['unique'].keys()]

        for unique in uniques:
            mat = self.IDs['unique'][str(gem.ItemID)]
            self.Counters['unique'][mat] += gem.Amount
            Items.Move(unique, self.Opt['homechest']['gem'], 0)
            Misc.Pause(self.Delay['drag'])

        rocks = [r for r in Player.Backpack.Contains if r.ItemID == self.IDs['rock']]

        for rock in rocks:
            mat = self.IDs['color'][str(rock.Hue)]
            self.Counters['rock'][mat] += rock.Amount
            Items.Move(rock, self.Opt['homechest']['rock'], 0)
            Misc.Pause(self.Delay['drag'])

        sand = next(s for s in Player.Backpack.Contains if s.ItemID == self.IDs['sand'])
        
        if not sand is None:
            self.Counters['sand'] += sand.Amount
            Items.Move(sand, self.Opt['homechest']['rock'], 0)
            Misc.Pause(self.Delay['drag'])
            
        self.SaveCounts()
        
    def GoHome(self):
        while not self.ImHome:
            for rune in xrange(self.Opt['homerune'][0], self.Opt['homerune'][1] + 1):
                
                if Journal.Search('blocked.'):
                    Journal.Clear()
                    Misc.Pause(self.Delay['recovery'])
                    
                r = rune * 6 + 5 + 2 * int(self.Opt['chivalry'])
                Items.UseItem(self.Opt['homebook'])
                Gumps.WaitForGump(1431013363, self.Delay['timeout'])            
                Gumps.SendAction(1431013363, r)
                Misc.Pause(self.Delay['cast'])

        while Player.Position.X != self.Opt['homepos']['x'] or Player.Position.Y != self.Opt['homepos']['y']:
            Player.PathFindTo(self.Opt['homepos']['x'], self.Opt['homepos']['y'], self.Opt['homepos']['z'])
            Misc.Pause(self.Delay['timeout'])

        self.Deposit()
                
    def Recall(self):
        Journal.Clear()
        while Player.Mana < 10:
            Misc.Pause(500)
        # flizz prevention
        _x = Player.Position.X
        _y = Player.Position.Y
        Gumps.ResetGump()
        Items.UseItem(self.Current['book'])
        Gumps.WaitForGump(1431013363, self.Delay['timeout'])            
        Gumps.SendAction(1431013363, self.Current['rune'])
        Misc.Pause(self.Delay['cast'])
        if Journal.Search("blocked.") or self.ImHome:            
            Misc.Pause(self.Delay['recovery'])
            self.Current['rune'] += 6
            if self.Current['rune'] > (95 + int(self.UseChivalry) * 2):
                self.Current['rune'] = 5 + int(self.UseChivalry) * 2
                bindex = self.Minebook.index(self.Current['book'])
                if bindex >= len(self.Minebook):
                    self.Current['book'] = self.Trees['book'][0]
                else:
                    self.Current['book'] = self.Trees['book'][bindex+1]
            self.Recall()
        elif Journal.Search("recover") or self.ImHome:
            Misc.Pause(self.Delay['recovery'])
            self.Recall()
        elif Player.Position.X == _x and Player.Position.Y == _y:
            Misc.Pause(self.Delay['recovery'])
            self.Recall()

    def GetSpots(self):
        self.Spots = []
        for x in xrange(Player.Position.X - Radius, Player.Position.X + Radius + 1):
            for y in xrange(Player.Position.Y -Radius, Player.Position.Y + Radius + 1):
                tile = Statics.GetLandID(x,y,Player.Map)
                
                if tile > -1 and tile in self.MineTiles:
                    z = Statics.GetLandZ(x,y,Player.Map)
                    self.Spots.append(MineSpot(x, y, z, tile))
                
    def Mine(self):
        for spot in self.Spots:
            while not Journal.Search('no ore here') and not Journal.Search('cannot be seen') and not Journal.Search('mine here'):
                self.CheckShovel()
                
                if self.IsOverWeight:
                    self.GoHome()
                    self.Recall()
                    
                Items.UseItemByID(self.IDs['shovel'])
                Target.WaitForTarget(self.Delay['timeout'])
                Target.TargetExecute(spot.X, spot.Y, spot.Z)
                Misc.Pause(self.Delay['dig'])
                
                if not self.Opt['firebeetle'] is None:
                    ores = [o for o in Player.Backpack.Contains if o.ItemID in self.IDs['ore']]
                        
                    for ore in ores:
                        Items.UseItem(ore)
                        Target.WaitForTarget(self.Delay['timeout'])
                        Target.TargetExecute(self.Opt['firebeetle'])
                        Misc.Pause(self.Delay['smelt'])
                        
    def Main(self):
        while True:
            for book in self.Minebook:
                for rune in xrange(16):
                    r = rune * 6 + 5 + 2 * int(self.UseChivalry)
                    self.Current = {'book' : book, 'rune' : r}
                    self.Recall()
                    self.GetSpots()
                    self.Mine()
Пример #15
0
    clr.AddReference("sbs_library")
    from SbsTest import C
    o = C()
    g1 = o.M1
    g2 = o.M2
    g3 = o.M3

    #for peverify runs
    from System.IO import Path, File, Directory
    if File.Exists(Path.GetTempPath() + r"\sbs_library.dll"):
        try:
            File.Delete(Path.GetTempPath() + r"\sbs_library.dll")
        except:
            pass
    if not File.Exists(Path.GetTempPath() + r"\sbs_library.dll"):
        File.Copy(Directory.GetCurrentDirectory() + r"\sbs_library.dll",
                  Path.GetTempPath() + r"\sbs_library.dll")

else:
    g1 = f1
    g2 = f2
    g3 = f3

# combinations
choices = [(), (0, ), (1, ), (2, ), (3, ), (0, 1), (0, 2), (0, 3), (1, 2),
           (1, 3), (2, 3), (0, 1, 2), (0, 1, 3), (0, 2, 3), (1, 2, 3),
           (0, 1, 2, 3)]


def to_str(l):
    return [str(x) for x in l]
Пример #16
0
    clr.AddReference("sbs_library")
    from SbsTest import C
    o = C()
    g1 = o.M1
    g2 = o.M2
    g3 = o.M3
    
    #for peverify runs
    from System.IO import Path, File, Directory
    if File.Exists(Path.GetTempPath() + r"\sbs_library.dll"):
        try:
            File.Delete(Path.GetTempPath() + r"\sbs_library.dll")
        except:
            pass
    if not File.Exists(Path.GetTempPath() + r"\sbs_library.dll"):
        File.Copy(Directory.GetCurrentDirectory() + r"\sbs_library.dll", Path.GetTempPath() + r"\sbs_library.dll")
    
else:
    g1 = f1
    g2 = f2
    g3 = f3

# combinations
choices = [(), (0,), (1,), (2,), (3,), (0, 1), (0, 2), (0, 3), (1, 2), (1, 3), (2, 3), (0, 1, 2), (0, 1, 3), (0, 2, 3), (1, 2, 3), (0, 1, 2, 3) ]

def to_str(l): return [str(x) for x in l] 

def replace_B(line):
    count = 0
    while True:
        pos = line.find("B")
Пример #17
0
# Variabili Sistema
import clr
clr.AddReference('System.Web.Extensions')
from System.Collections.Generic import List
from time import time
import math
from System.Net import WebRequest
from System.IO import StreamReader, Directory, Path, File
from System.Web.Script.Serialization import JavaScriptSerializer

CONFIGS = {}
RESOURCES = None
config_path = Path.Combine(Directory.GetCurrentDirectory(),
                           'Scripts\\json\\fishing_config.json')

with open(config_path, 'r') as f:
    CONFIGS = JavaScriptSerializer.DeserializeObject(JavaScriptSerializer(),
                                                     f.read())


class Spot(object):
    def __init__(self, x, y):
        self.x = Player.Position.X + x
        self.y = Player.Position.Y + y


class Fishing(object):
    ship_key = None
    fish_pos = {'x': None, 'y': None, 'z': None}
    keep = []
    spots = []
Пример #18
0
# -*- coding: utf-8 -*-
#作者:王卫生
#时间:2013-3-30

import sys
import clr
#import System

#添加VB DLL的目录
from System.IO import Directory, Path
directory = Directory.GetCurrentDirectory()
binpath = Path.Combine(directory, 'bin\\')
binpath = 'D:\\wangws\\sap_interface_project\\SAPAutomation\\SAPGuiInspector\\bin\\release\\'
#sys.path.append(r'D:\wangws\sap_interface_project\SAPAutomation\SAPGuiInspector\bin\Debug')
#sys.path.append(System.AppDomain.CurrentDomain.BaseDirectory)
sys.path.append(binpath)

filename = 'SapGuiApplicationVB.dll'

clr.AddReferenceToFile(filename)

from SapGuiApplicationVB import *
sapgui = SapGuiConnector()

Session = sapgui.getSessionByTcode("MB03")

import System
from System.Collections import *
h = Hashtable()
h["a"] = "IronPython"
Пример #19
0
from System.IO import Directory, Path

this_dir = Directory.GetCurrentDirectory()

# import this to load the correct standard library
# As a side effect it changes directory
from runworkbook import RunWorkbook

# Needed for unittest - not shipped with Resolver One
import sys
sys.path.append(r'C:\Python25\Lib')
import unittest

from System.Drawing import Color

from Library.CellRange import CellRange
from Library.Worksheet import Worksheet

Directory.SetCurrentDirectory(this_dir)
spreadsheet_path = Path.Combine(this_dir, 'TestableSheet.rsl')


class TestableSheetTest(unittest.TestCase):
    def testWorksheets(self):
        workbook = RunWorkbook(spreadsheet_path, useCache=True)

        worksheets = [sheet.Name for sheet in workbook]
        self.assertEquals(worksheets, ['Data'],
                          "Incorrect worksheets in spreadsheet")

    def testBasicSpreadsheetConfiguration(self):
Пример #20
0

# set up directory watcher to automatically reload
def _watcher_reload(source, event):

    if event.Name in ("commands.py", "config.py", "events.py"):
        error = None
        try:
            _reload()
        except IOException:
            # file can still be held by write process and reload fails - retry
            _watcher_reload(source, event)
        except SyntaxError, e:
            if "The process cannot access the file" in str(e):
                _watcher_reload(source, event)
            else:
                error = e
        except Exception, e:
            error = e
        if error:
            print "reload error: %s" % error


_watcher = FileSystemWatcher()
_watcher.Path = Directory.GetCurrentDirectory()
_watcher.Changed += _watcher_reload
_watcher.EnableRaisingEvents = True

if __name__ == "__main__":
    import run
Пример #21
0
import clr
import sys
from System.IO import Directory, Path

sys.path.append(Directory.GetCurrentDirectory())
clr.AddReferenceToFile('OECLib.dll')

from OECLib.HTTPRequests import HTTPRequest


def Initialize():
    return


def GetName():
    return "Exoplanet.EU"


def GetDescription():
    return "This plugin allows the extraction of data from the exoplanet.eu database"


def Run():
    webRequest = HTTPRequest()
    print webRequest.RequestAsString("www.google.ca")
    print "{0}: {1}".format(GetName(), GetDescription())
Пример #22
0
# NtBuildNumber == kernel version
#
import clr, sys
import System
clr.AddReferenceToFileAndPath("inVtero.net.dll")
clr.AddReferenceToFileAndPath("inVtero.net.ConsoleUtils.dll")
from inVtero.net import *
from inVtero.net.ConsoleUtils import *
from inVtero.net.Hashing import *
from System.IO import Directory, File, FileInfo, Path
from System import Environment, String, Console, ConsoleColor
from System import Text
from System.Diagnostics import Stopwatch
from List import *

print "\n\n\tCurrent directory [" + Directory.GetCurrentDirectory() + "]"

# This script can be pretty chatty to stdout, configure various output here
Vtero.VerboseOutput = True
Vtero.DiagOutput = False
Vtero.VerboseLevel = 1
Vtero.DisableProgressBar = True

# More option handling for each file
copts = ConfigOptions()
copts.IgnoreSaveData = True
copts.VersionsToEnable = PTType.GENERIC
copts.VerboseLevel = 1
# in the case of some dump tools (ENCASE) use this option
#copts.ForceSingleFlatMemRun = True
Пример #23
0
def onClick(s, e):
    currentDirectory = Directory.GetCurrentDirectory()

    openFileDialog = OpenFileDialog()
    openFileDialog.Multiselect = False

    if CultureInfo.CurrentCulture.Equals(CultureInfo.GetCultureInfo("ja-JP")):
        openFileDialog.Filter = "XMLファイル (*.xml)|*.xml"
    else:
        openFileDialog.Filter = "XML files (*.xml)|*.xml"

    if openFileDialog.ShowDialog() == True:
        fileName = openFileDialog.FileName
        warningList = List[String]()
        errorList = List[String]()

        context = TaskScheduler.FromCurrentSynchronizationContext()

        def onValidate():
            fs = None

            try:
                fs = FileStream(fileName, FileMode.Open, FileAccess.Read,
                                FileShare.Read)

                doc = XmlDocument()
                doc.Load(fs)

                if doc.DocumentElement.Name.Equals("script"):
                    for childNode1 in doc.DocumentElement.ChildNodes:
                        if childNode1.Name.Equals("character"):
                            hasName = False

                            for xmlAttribute in childNode1.Attributes:
                                if xmlAttribute.Name.Equals("name"):
                                    hasName = True

                            if not hasName:
                                if CultureInfo.CurrentCulture.Equals(
                                        CultureInfo.GetCultureInfo("ja-JP")):
                                    errorList.Add("characterタグにname属性がありません。")
                                else:
                                    errorList.Add(
                                        "Could not find name attribute in character tag."
                                    )

                            for childNode2 in childNode1.ChildNodes:
                                if childNode2.Name.Equals("sequence"):
                                    parseSequence(
                                        childNode2,
                                        Path.GetDirectoryName(fileName),
                                        warningList, errorList)

                else:
                    if CultureInfo.CurrentCulture.Equals(
                            CultureInfo.GetCultureInfo("ja-JP")):
                        errorList.Add("scriptタグがありません。")
                    else:
                        errorList.Add("Could not find script tag.")

            except Exception, e:
                errorList.Add(e.clsException.Message)

            finally: