Exemplo n.º 1
0
    def load(self):
        drivers = []
        if self.config.has('drivers-use'):
            drivers += self.config.getAsList('drivers-use')

        for driver in drivers:
            LoadedDrivers.load(driver)

        if self.options.debug:
            self.log.log('>> Finished Loading Drivers')
            self.log.log('')
            self.log.log('')

        self.log.getLoggerDriver().outputLog()
Exemplo n.º 2
0
def execute_string(
        code: str,
        debug: bool = False) -> Tuple[BlockStatus, AhVisitor, float]:
    Drivers.add("scriptax", ScriptaxDriver(path="~/"))
    LoadedDrivers.load("scriptax")

    drivers_path = Path(
        Path(__file__).resolve().parents[1]).joinpath('drivers.json')
    packages = list(drivers_path)
    for key, value in packages.items():
        drivers = value['drivers']

        # Imports default driver
        try:
            module = importlib.import_module(key + '.drivers.driver')
            Drivers.add(key, module.driver)
            LoadedDrivers.load(key)
        except:
            print("Unable to load default driver inside of package: " + key)

        # Imports other drivers
        for driver in drivers:
            try:
                module = importlib.import_module(key + '.drivers.' + driver)
                Drivers.add(key + "_" + driver, module.driver)
                LoadedDrivers.load(key + "_" + driver)
            except:
                print("Unable to load driver `" + driver +
                      "` inside of package: " + key)

    start_time = time.process_time()
    block_status, ahvisitor = customizable_parser(read_string(code),
                                                  options=Options(debug=debug))
    total_time = time.process_time() - start_time
    return block_status, ahvisitor, total_time
Exemplo n.º 3
0
from apitaxcore.flow.LoadedDrivers import LoadedDrivers
from apitaxcore.drivers.Drivers import Drivers

from apitaxcore.models.Options import Options

State.log = Log(StandardLog(), logColorize=False)

State.log.log("> test")
State.log.log("")

Drivers.add("commandtax", Commandtax())
Drivers.add("scriptax", Scriptax())
Drivers.add("std", StandardLibrary())
Drivers.add("api", Api())
Drivers.add("apixml", ApiXml())
LoadedDrivers.load("commandtax")
LoadedDrivers.load("scriptax")
LoadedDrivers.load("std")
LoadedDrivers.load("api")
LoadedDrivers.load("apixml")

#scriptax = "from std import String as stdstr; log(stdstr.substr(text='this_is_some_fantastic_text', start=3, length=10));"
#scriptax = "from std import Map as map; mymap = new map(); mymap.map.test = 'wtf'; mymap.map.bob = 'yes'; mymap.map.shawn = {'noway': 'yesway'}; log(mymap.has(key='noway', sMap=mymap.map.shawn)); return 'test complete';"
#scriptax = "from std import Restapi as stdapi; mydata = {}; mydata.title = 'awesome'; mydata.body='shawn is'; mydata.id=5; log(stdapi.jget(endp='https://jsonplaceholder.typicode.com/posts')); log(stdapi.jpost(endp='https://jsonplaceholder.typicode.com/posts', dataPost=mydata)); return 'test complete';"
#scriptax = "from std import Restapi as stdapi; mydata = {}; mydata.title = 'awesome'; mydata.body='shawn is'; mydata.id=555; log(stdapi.jpost(endp='https://jsonplaceholder.typicode.com/posts', dataPost=mydata)); return 'test complete';"
#scriptax = "from std import Restapi(debug=true) as stdapi; mydata = {}; mydata.title = 'awesome'; mydata.body='shawn is'; mydata.id=555; log(stdapi.dpost(driver='api',endp='https://jsonplaceholder.typicode.com/posts', dataPost=mydata)); return 'test complete';"
#scriptax = "from std import Json as stdjson; mydata = {}; mydata.title = 'awesome'; mydata.body='shawn is'; mydata.id=555; log(mydata); log(stdjson.toJson(obj=mydata)); log(ct('api --url https://jsonplaceholder.typicode.com/posts --post --data-post \\\'' + stdjson.toJson(obj=mydata) + '\\\''));"

#scriptax = "from std import Restapi(debug=true) as stdapi; mydata = {}; mydata.title = 'awesome'; mydata.body='shawn is'; mydata.id=555; mydata.something = {}; mydata.somnething={\"address\":\"address\",\"city\":\"Regina\",\"email\":\"[email protected]\",\"extra\":{},\"fax\":\"123456789\",\"name\":\"Tristans Legit Clinic\",\"phone_number\":\"987654321\",\"province\":\"Saskatchewan\"}; log(mydata); log(stdapi.dpost(driver='api',endp='https://jsonplaceholder.typicode.com/posts', dataPost=mydata)); return 'test complete';"

scriptax = "from std import Json as stdjson; from std import Restapi(debug=true) as stdapi; mydata={\"address\":\"address\",\"city\":\"Regina\",\"email\":\"[email protected]\",\"extra\":{},\"fax\":\"123456789\",\"name\":\"Tristans Legit Clinic\",\"phone_number\":\"987654321\",\"province\":\"Saskatchewan\"}; log(mydata); log(ct('api --url https://jsonplaceholder.typicode.com/posts --post --data-post \\\'' + stdjson.toJson(obj=mydata) + '\\\''));"
Exemplo n.º 4
0
# Application import
from scriptax.parser.utils.BoilerPlate import customizable_parser
from scriptax.drivers.builtin.Scriptax import Scriptax

from apitaxcore.logs.Log import Log
from apitaxcore.logs.StandardLog import StandardLog
from apitaxcore.models.State import State
from apitaxcore.flow.LoadedDrivers import LoadedDrivers
from apitaxcore.drivers.Drivers import Drivers

State.log = Log(StandardLog(), logColorize=False)

State.log.log("> test")

Drivers.add("scriptax", Scriptax())
LoadedDrivers.load("scriptax")

#scriptax = "from scriptax import test.testing as Tester;"
#scriptax += "from scriptax import test.meow as MEOWWW;"
# scriptax += "from scriptax import bob.bob(testingthis='kk') as Wahp;"
# scriptax += "api someMethod () {log('TESTING SOME METHOD'); log(parent.variableTest);}"
# scriptax += "api paramMethod(test) {log(test);}"
# scriptax += "api returnMethod() {return 'wazzup';log('THIS SHOULD NOT BE REACHABLE');}"
# scriptax += "log(\"test\"); log(2+4/4); variableTest=5; variableTest='okay'; shawn=True; tristan=None; jen=0X678; if(shawn) {bob=42;log(jen); if(True) {log('help me pls');log(variableTest + 5 / 3);}} someInstance = new Tester();"
# scriptax += "log('break');"
# scriptax += "someInstance.setPath(path='methods are good to go');someMethod();someInstance.getPath();someInstance.resetPath();someInstance.getPath();Tester.getPath();Tester.resetPath();MEOWWW.getPath();"
# scriptax += "variableTest=5; if(shawn && variableTest > 5) return someInstance.addOne(num=5.1);"
# scriptax += "paramMethod(test='no way');log(returnMethod());log(someInstance.addOne(num=5));"
# scriptax += "bobInstance = new Wahp(testingthis='yeee');bobInstance.doBob();log(bobInstance.addOne(somenum=43));"
# scriptax += "someVar = {'bob': 5}; someVar.bob = 6; someVar.shawn = 'test'; log(someVar.shawn);"
# scriptax += "someDict = {'blerp': 0x987abc}; someVar.shawn = someDict; log(someVar.shawn.blerp);"
Exemplo n.º 5
0
from scriptaxstd.drivers.builtin.Api import Api
from scriptaxstd.drivers.builtin.ApiXml import ApiXml
from apitax.drivers.builtin.BasicAuth import BasicAuth
from apitax.drivers.builtin.Apitax import Apitax

# Adding imported drivers into app
Drivers.add("commandtax", Commandtax())
Drivers.add("scriptax", Scriptax())
Drivers.add("std", StandardLibrary())
Drivers.add("api", Api())
Drivers.add("api-xml", ApiXml())
Drivers.add("basic-auth", BasicAuth())
Drivers.add("apitax", Apitax())

# Loading added drivers
LoadedDrivers.load("commandtax")
LoadedDrivers.load("scriptax")
LoadedDrivers.load("std")
LoadedDrivers.load("api")
LoadedDrivers.load("api-xml")
LoadedDrivers.load("basic-auth")
LoadedDrivers.load("apitax")

# Importing/Adding custom project drivers
project.loadDrivers()

# Finishes loading app by loading custom drivers as specified in the config
setup.load()

# This loads the app for use in both the uWSGI and Nginx mode as well as dev server mode
from apitax.api.Server import *