コード例 #1
0
def execute_step(event, function_name, function_input, function_output, function_args):
    importdir.do("/app/python_scripts", globals())
    try:
        function_mod,function_call = function_name.split('.',2)
        active_function = getattr(globals()[function_mod], function_call)
        event = active_function(event, function_input, function_output, function_args)
    except Exception as e:
        event = append_keyvalue(event,"status",str(e))
    return event
コード例 #2
0
 def __init__(self):
     self.shema_dir = ""
     self.Controller = ""
     self.Action = ""
     init = Init.Init()
     init.config_file = '/home/leo/emualator/web/app/etc/site.conf'
     init.read_config()
     init.init_database()
     importdir.do(init.config['CONTROLLERS']['controller_dir'], globals())
コード例 #3
0
def execute_script(item: ExecuteScriptInputs):
    importdir.do("/app/python_scripts", globals())
    function_input = item.function_input
    try:
        active_function = getattr(globals()[item.module_name],item.function_name)
    except:
        return "module/function not found"
    try:
        function_result = active_function(item.event,item.function_input,item.function_output,item.function_args)
        return function_result
    except:
        return "Error while executing function"
コード例 #4
0
ファイル: config.py プロジェクト: geeks121/escrow-service-bot
import os
import telegram
import telebot
from telebot import types
import emoji
from blockchain import blockexplorer
from flask import Flask, request, render_template
from coinbase.wallet.client import Client
from dotenv import load_dotenv
load_dotenv()

DEBUG = False

# Configuration variable
TOKEN = os.getenv("TOKEN")

ADMIN_ID = os.getenv("ADMIN_ID")

# Coinbase API for payments
API_KEY = os.getenv("API_KEY")
API_SECRET = os.getenv("API_SECRET")

bot = telebot.AsyncTeleBot(TOKEN, threaded=True)

import importdir
importdir.do("handlers", globals())
コード例 #5
0
ファイル: LCS_bot.py プロジェクト: mathieuzen/lol
from colorclass import Color

print(Color('{autored}[{/red}{autoyellow}+{/yellow}{autored}]{/red} {autocyan}Cargando plugins...{/cyan}'))

from config import *
import importdir
import sys

#################################################
#                    BOT BODY                   #
#################################################

if sys.version_info.major < 3:
    raise Exception("Must be using Python 3")

importdir.do('plugins', globals())

print(Color('{autored}[{/red}{autoyellow}+{/yellow}{autored}]{/red} {autocyan}Plugins cargados.{/cyan}'))


try:
	logBot.send_message( 52033876, "@League_of_Legends_bot ha sido encendido")
except Exception as e:
	bot.send_message( 52033876, str(e))

print(Color('{autored}[{/red}{autoyellow}+{/yellow}{autored}]{/red} {autocyan}@League_of_Legends_bot ha sido encendido.{/cyan}\n'))

#################################################
#                    POLLING                    #
#################################################
コード例 #6
0
ファイル: env.py プロジェクト: bitson/bitsonbot
from __future__ import with_statement
from alembic import context
from sqlalchemy import engine_from_config, pool
from logging.config import fileConfig
import importdir

importdir.do('models', globals())
from utils import Base
# this is the Alembic Config object, which provides
# access to the values within the .ini file in use.
config = context.config

# Interpret the config file for Python logging.
# This line sets up loggers basically.
fileConfig(config.config_file_name)

# add your model's MetaData object here
# for 'autogenerate' support
# target_metadata = mymodel.Base.metadata
target_metadata = Base.metadata

# other values from the config, defined by the needs of env.py,
# can be acquired:
# my_important_option = config.get_main_option("my_important_option")
# ... etc.


def run_migrations_offline():
    """Run migrations in 'offline' mode.

    This configures the context with just a URL
コード例 #7
0
from eppy import modeleditor
from eppy.modeleditor import IDF
import csv
import importdir

# Initialization #1
importdir.do("Functions", globals())
IDDFile = 'C:\EnergyPlusV8-3-0\Energy+.idd'
IDF.setiddname(IDDFile)
BatchProcesingFile = open("BatchProcessing.csv", "r")
BatchProcessing = list(
    csv.reader(BatchProcesingFile, delimiter=',', quotechar=chr(34)))
Idx = 0

for i in range(0, len(BatchProcessing)):
    # Display the progress of the script
    if Idx >= 2:
        print "Creating " + str(Idx - 1) + " out of " + str(
            len(BatchProcessing) - 2) + " models."

    # Initialization #2
    NbRows = BatchProcessing[i]
    if NbRows[0] <> 'idf' and NbRows[0] <> '-':
        # Initialization #3
        idf_file = IDF(NbRows[0])

        # Iterates throught the CSV file and execute the specified functions
        for j in range(2, len(NbRows)):

            # Retrieve the user input arguments
            arguments = NbRows[j].split(",")
コード例 #8
0
# coding=UTF-8

from config import *

import importdir
importdir.do('plugins', globals())

# Pool for messages
bot.polling(none_stop=True)
コード例 #9
0
import importdir
import os
importdir.do(os.getcwd(), globals())
コード例 #10
0
ファイル: RRR.py プロジェクト: Tronikart/RadRetroRobot
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from utils import *
import importdir

importdir.do("plugins", globals())

try:
    bot.send_message(adminid, "*Bot loaded and ready for action!*", parse_mode="Markdown")
except:
    pass


def poll(option):
    if option == "debug":
        print "Bot: debug mode"
        bot.polling(True)
    else:
        try:
            print "Bot: running"
            bot.polling(none_stop=False, interval=0)
        except KeyboardInterrupt:
            pass
        except:
            try:
                print "\nUnexpected error:", sys.exc_info()[0]
                print "\n\t" + unicode(sys.exc_info()[1]) + "\n"
                bot.send_message(
                    adminid,
                    "\n*Unexpected error:*\n"
コード例 #11
0
import sys
import inspect

if(len(sys.argv) <= 1):
    print("Provide -get or -set arg")
    sys.exit()

if "-debug" in sys.argv:
    sys.tracebacklimit = 1000
else:
    sys.tracebacklimit = 0

PLUGINS = "devices/"

try:
    importdir.do(PLUGINS, globals())
except:
    print("Error loading some devices")
    print("If needed, use -debug to print full trace")

mods = importdir.__get_module_names_in_dir("devices/")

if(str(sys.argv[1]) == "-get"):
    for val in mods:
        module = __import__(val)
        if hasattr(module,"lampget"):
            if(len(sys.argv)>2):
                if(str(sys.argv[2]) == str(module.DEVICE_ID)):
                    print(module.lampget())
                    break
            else:
コード例 #12
0
import cherrypy
import os
import sys
import json

currDir = os.path.abspath(os.path.dirname(__file__))
libDir = currDir + '/../lib'
sys.path.append(libDir)
#sys.path.insert(0, r'/')
#importdir.do(libDir, globals())
import importdir
importdir.do(libDir, globals())


def import_from(module, name, str):
    module = __import__(module, fromlist=[name])
    v = getattr(module, name)(str)
    return v


@cherrypy.popargs('function')
class automation_rest_api(object):
    @cherrypy.expose
    @cherrypy.tools.json_in()
    @cherrypy.tools.json_out()
    def index(self, function):
        cherrypy.log('function name: ' + function)
        if not (os.path.exists(libDir + '/' + function + '.py')):
            return 'FATAL: Invalid function'
        outJson = {}
        JsonArgs = cherrypy.request.json
コード例 #13
0
ファイル: main.py プロジェクト: SmexxarN/smexxbot_tg
import tgl

#Import commands
import importdir
importdir.do("commands", globals())
importdir.get_names("commands")
module_list = importdir.module_list

tgl.PEER_USER = 1
tgl.PEER_CHAT = 2
tgl.PEER_ENCR_CHAT = 4

allow_messages = False
bot_id = ""


def on_binlog_replay_end():
    "This is called when replay of old events end. Any updates prior this call were already received by this client some time ago."


def on_get_difference_end():
    "This is called after first get_difference call. So we received all updates after last client execute."
    #Finished launching, allowing commands now
    global allow_messages
    allow_messages = True


def on_our_id(our_id):
    "Informs about id of currently logged in user."
    global bot_id
    bot_id = our_id
コード例 #14
0
ファイル: main.py プロジェクト: SmexxarN/smexxbot_tg
import tgl

#Import commands
import importdir
importdir.do("commands", globals())
importdir.get_names("commands")
module_list = importdir.module_list

tgl.PEER_USER = 1
tgl.PEER_CHAT = 2
tgl.PEER_ENCR_CHAT = 4

allow_messages = False
bot_id = ""


def on_binlog_replay_end():
	"This is called when replay of old events end. Any updates prior this call were already received by this client some time ago."
	
def on_get_difference_end():
	"This is called after first get_difference call. So we received all updates after last client execute."
	#Finished launching, allowing commands now
	global allow_messages
	allow_messages = True
	
def on_our_id(our_id):
	"Informs about id of currently logged in user."
	global bot_id
	bot_id = our_id
	
def on_msg_receive(msg):
コード例 #15
0
ファイル: config.py プロジェクト: bouncei/UserBot
fileName = ''

customImage = ''

with open('Test.csv', 'r', encoding="utf8") as file:
    reader = csv.DictReader(file)
    for row in reader:
        database.append(row['USERID'])

# Setup Logging
logger = telebot.logger
# telebot.logger.setLevel(logging.DEBUG)  # Outputs debug messages to console.
logging.basicConfig(filename='Log_file.log',
                    format='%(levelname)s: %(asctime)s %(message)s',
                    datefmt='%m/%d/%Y %I:%M:%S'
                    )  # saves debug messages in a file(Log_file.log)

### Define Variables ###

bot_token = "1727697640:AAERXgE0dkMYVgAzVP-AgRr97MVuuDK4DJg"

admin = 1190069449  ## PLEASE ADD YOUR CHAT ID HERE ##

bot = TeleBot(token=bot_token)

server = Flask(__name__)

import importdir

importdir.do("main", globals())
コード例 #16
0
ファイル: choir.py プロジェクト: xelaelyob/choir
"""
Choir is a test program used for demonstrating Github collaboration.

Step 1: Add a file to the `/lyrics` folder and create 2 functions:
sing(): Return a line of lyrics
credit(): Return a line crediting yourself for participation

Step 2: Add your file name (without the .py extension) the to MODULES array
"""
from time import sleep
import importdir

importdir.do("lyrics", globals())
"""
ADD YOUR FILE NAME HERE (without the .py extension):
"""
# pylint: disable=undefined-variable
#
MODULES = [first_example, second]
#
# pylint: enable=undefined-variable
"""
And that's all! We disable undefined variables since the modules
are loaded dynamically and aren't available before run-time and thus
will appear as an error
"""


def main():
    for module in MODULES:
        print(module.sing() + ' - ' + module.credit())
コード例 #17
0
import telegram
import time
from flask import Flask, request
import telebot
from telebot import types
from dotenv import load_dotenv
load_dotenv()

# Logging Setup
import logging
logging.basicConfig(
    format='[%(levelname) 5s/%(asctime)s] %(name)s: %(message)s',
    level=logging.WARNING)

TOKEN = os.getenv('TOKEN')

DEBUG = False

SERVER_URL = os.getenv("SERVER_URL")

FORGING_BLOCK_TOKEN = os.getenv("FORGING_BLOCK_TOKEN")

MAIL = os.getenv("MAIL")
PASS = os.getenv("PASS")

bot = telebot.TeleBot(TOKEN)
server = Flask(__name__)

import importdir
importdir.do("utils", globals())
コード例 #18
0
ファイル: app.py プロジェクト: j-sims/hantik
# Create Bottle instance
rootapp = Bottle()

#### Dynamically import addons
import importdir, glob
addons = []
addonmenus = {}
addondescriptions = {}

if not os.path.exists(APPDIR +'/addons/'):
    os.mkdir(APPDIR +'/addons/')

for i in glob.glob(os.path.dirname(APPDIR +'/addons/')+"/*/"):
    try:
        importdir.do(i, globals())
        addons.append(os.path.split(os.path.realpath(i))[1])
        modulename = addons[-1]
        rootapp.mount('/'+modulename, eval((modulename + '.app')))
    except Exception, err:
        log.error("Error importing module: %s" % err)

# Build Addon menu
for a in addons:
    try:
        addonmenus[a] = eval(a).menuitems()
        addondescriptions[a] = eval(a).describe()
    except Exception, err:
        log.error("Error importing %s: %s" %(a, err))

d['addonmenus'] = addonmenus
コード例 #19
0
ファイル: Main.py プロジェクト: lymereJ/EppyWorkflow
from eppy import modeleditor
from eppy.modeleditor import IDF
import csv
import importdir

# Initialization #1
importdir.do("Functions",globals())
IDDFile = 'C:\EnergyPlusV8-3-0\Energy+.idd'
IDF.setiddname(IDDFile)
BatchProcesingFile = open("BatchProcessing.csv","r")
BatchProcessing = list(csv.reader(BatchProcesingFile, delimiter=',', quotechar=chr(34)))
Idx = 0

for i in range(0,len(BatchProcessing)):
	# Display the progress of the script
	if Idx >= 2:
		print "Creating "+str(Idx-1)+" out of "+str(len(BatchProcessing)-2)+" models."
	
	# Initialization #2
	NbRows = BatchProcessing[i]
	if NbRows[0] <> 'idf' and NbRows[0] <> '-':
		# Initialization #3
		idf_file = IDF(NbRows[0])
		
		# Iterates throught the CSV file and execute the specified functions
		for j in range(2,len(NbRows)):
		
			# Retrieve the user input arguments
			arguments = NbRows[j].split(",")
			
			#print str(len(arguments))+" " +str(arguments[0])
コード例 #20
0
import telebot
import os
from config import *
from flask import Flask, request
server = Flask(__name__)

import importdir
importdir.do("features", globals())

@server.route('/'+ TOKEN, methods=['POST'])
def getMessage():
    request_object = request.stream.read().decode("utf-8")
    update_to_json = [telebot.types.Update.de_json(request_object)]
    bot.process_new_updates(update_to_json)
    return "got Message bro"

@server.route('/hook')
def webhook():
    url=URL
    bot.remove_webhook()
    bot.set_webhook(url + TOKEN)
    return f"Webhook set to {url}"

# @server.route('/round')
# def webhook()


if DEBUG==True:
    bot.remove_webhook()
    bot.polling()
else:
コード例 #21
0
ファイル: env.py プロジェクト: bitson/bitsonbot
from __future__ import with_statement
from alembic import context
from sqlalchemy import engine_from_config, pool
from logging.config import fileConfig
import importdir

importdir.do('models', globals())
from utils import Base
# this is the Alembic Config object, which provides
# access to the values within the .ini file in use.
config = context.config

# Interpret the config file for Python logging.
# This line sets up loggers basically.
fileConfig(config.config_file_name)

# add your model's MetaData object here
# for 'autogenerate' support
# target_metadata = mymodel.Base.metadata
target_metadata = Base.metadata

# other values from the config, defined by the needs of env.py,
# can be acquired:
# my_important_option = config.get_main_option("my_important_option")
# ... etc.


def run_migrations_offline():
    """Run migrations in 'offline' mode.

    This configures the context with just a URL