Exemple #1
0
	async def reload(self, msg: Message):
		# user check
		if not msg.author.id == utils.enderzombi():
			await msg.channel.send('only ENDERZOMBI102 can do that')
			return
		module: str = msg.content.replace('reload', '', 1).strip()
		if not len( module ) > 0:
			if self.lastReload is None:
				await msg.channel.send('missing parameter')
				return
			else:
				module = self.lastReload
		self.lastReload = module
		await msg.channel.send(f'reloading module "{module}"')
		if module in self.module.modules.keys():
			try:
				await self.module.reload(module)
			except Exception as e:
				await msg.channel.send( embed=utils.getTracebackEmbed(e) )
				raise e
			else:
				await msg.channel.send(f'custom module "{module}" reloaded')
		else:
			if module == 'modules':
				try:
					importlib.reload( modules )
				except Exception as e:
					await msg.channel.send( embed=utils.getTracebackEmbed(e) )
					return
				else:
					self.module = modules.Modules()
					self.module.bot = self
			elif module == 'commands':
				try:
					importlib.reload(commands)
				except Exception as e:
					await msg.channel.send( embed=utils.getTracebackEmbed(e) )
					return
				else:
					self.stdCommands = commands.Commands()
					self.stdCommands._bot = self
			elif module == 'utils':
				try:
					importlib.reload(utils)
				except Exception as e:
					await msg.channel.send( e )
					return
				else:
					self.stdCommands = commands.Commands()
					self.stdCommands._bot = self
			else:
				await utils.send(msg, 'invalid module "{module}"')
				return
			await msg.channel.send(f'bot module "{module}" reloaded')
Exemple #2
0
	def __init__(self):
		# load saved data
		with open('./options', 'r') as file:
			data = bjson.load(file)
		self.prefix = data['bot']['prefix']
		# init stuff
		indents = discord.Intents.all()
		indents.presences = False
		# noinspection PyArgumentList
		self.client = discord.Client(
			intents=indents
		)
		self.client.event( self.on_ready )
		self.client.event( self.on_message )
		self.client.event( self.on_member_join )
		self.client.event( self.on_member_leave )
		self.client.event( self.on_member_update )
		self.eventChannel = data['bot']['eventChannel']
		self.module = modules.Modules()
		self.stdCommands = commands.Commands()
		Bot._instance = self
Exemple #3
0
def main():
    """Funkcja wykonująca cały program"""
    modul = modules.Modules()
    fun = function.Functions()
    file = files.Files()
    register = registration.Registration()

    files_with_code = pythonfiles.FileInDirectory()
    path = r'.\\'
    extend = 'py'
    result = files_with_code.list_directory(path, extend)

    files.Files.checking_connections_between_files(result)

    function_list1 = function.Functions.checking_connections_between_functions1(
        result)
    function_list2 = fun.checking_weight_of_connections_between_functions(
        result, function_list1)
    weight_fun = functions.write_to_file_fun_data(function_list1,
                                                  function_list2)
    function.Functions.checking_connections_between_functions(
        result, weight_fun)
    modul_list = modules.Modules.searching_for_used_modules(result)
    modules.Modules.checking_connections_between_modules(result, modul_list)

    join_list = functions.convert_list_to_list_for_cc(
        files.Files.filesConnectionList, modules.Modules.modulConnectionList)
    join_list = list(set(join_list))

    cyclomatic_complexity = functions.cyclomatic_complexity()
    cyclomatic_complexity = functions.compare(function_list1,
                                              cyclomatic_complexity)
    cyclomatic_complexity += join_list
    menu_choice = functions.menu()

    if menu_choice == 1:
        registration.Registration.write_to_file(
            "FILES", files.Files.filesConnectionList
        )  # Wpisywanie do pliku połączeń plików
        registration.Registration.write_to_file(
            "", files.Files.filesConnectionWeight)

    elif menu_choice == 2:
        registration.Registration.write_to_file(
            "Functions", function.Functions.functionsConnectionList
        )  # Wpisywanie do pliku połączeń funkcji
        registration.Registration.write_to_file(
            "", function.Functions.functionsConnectionWeight)
        registration.Registration.write_to_file("CYCLOMATIC_COMPLEXITY",
                                                cyclomatic_complexity)

    elif menu_choice == 3:
        registration.Registration.write_to_file(
            "Modules", files.Files.filesConnectionList
        )  # Wpisywanie do pliku połączeń modułów
        registration.Registration.write_to_file(
            "", modul.Modules.modulConnectionWeight)

    elif menu_choice == 4:
        registration.Registration.write_to_file(
            "FILES", files.Files.filesConnectionList
        )  # Wpisywanie do pliku połączeń plików
        registration.Registration.write_to_file(
            "", files.Files.filesConnectionWeight)

        registration.Registration.write_to_file(
            "Functions", function.Functions.functionsConnectionList
        )  # Wpisywanie do pliku połączeń funkcji
        registration.Registration.write_to_file(
            "", function.Functions.functionsConnectionWeight)
        registration.Registration.write_to_file("CYCLOMATIC_COMPLEXITY",
                                                cyclomatic_complexity)

    elif menu_choice == 5:
        registration.Registration.write_to_file(
            "FILES", files.Files.filesConnectionList
        )  # Wpisywanie do pliku połączeń plików
        registration.Registration.write_to_file(
            "", files.Files.filesConnectionWeight)

        registration.Registration.write_to_file(
            "Modules", modules.Modules.modulConnectionList
        )  # Wpisywanie do pliku połączeń modułów
        registration.Registration.write_to_file(
            "", modules.Modules.modulConnectionWeight)

    elif menu_choice == 6:
        registration.Registration.write_to_file(
            "Functions", function.Functions.functionsConnectionList
        )  # Wpisywanie do pliku połączeń funkcji
        registration.Registration.write_to_file(
            "", function.Functions.functionsConnectionWeight)

        registration.Registration.write_to_file(
            "Modules", modules.Modules.modulConnectionList
        )  # Wpisywanie do pliku połączeń modułów
        registration.Registration.write_to_file(
            "", modules.Modules.modulConnectionWeight)
        registration.Registration.write_to_file("CYCLOMATIC_COMPLEXITY",
                                                cyclomatic_complexity)

    elif menu_choice == 7:
        registration.Registration.write_to_file(
            "FILES", files.Files.filesConnectionList
        )  # Wpisywanie do pliku połączeń plików
        registration.Registration.write_to_file(
            "", files.Files.filesConnectionWeight)

        registration.Registration.write_to_file(
            "Functions", function.Functions.functionsConnectionList
        )  # Wpisywanie do pliku połączeń funkcji
        registration.Registration.write_to_file(
            "", function.Functions.functionsConnectionWeight)

        registration.Registration.write_to_file(
            "Modules", modules.Modules.modulConnectionList
        )  # Wpisywanie do pliku połączeń modułów
        registration.Registration.write_to_file(
            "", modules.Modules.modulConnectionWeight)
        registration.Registration.write_to_file("CYCLOMATIC_COMPLEXITY",
                                                cyclomatic_complexity)

    else:
        print("Wybrałeś opcję z poza zakresu")
        main()
Exemple #4
0
import json, sys, os
from pyapi import PYAPI
import modules
m_obj = modules.Modules()
import db.get_conn as get_conn
conn_obj = get_conn.DB()


def disableprint():
    sys.stdout = open(os.devnull, 'w')
    pass


def enableprint():
    sys.stdout = sys.__stdout__


class WebAPI(PYAPI):
    def __init__(self):
        PYAPI.__init__(self)

    def process(self, cmd_id, ijson):
        res = []
        if 1 == cmd_id:
            res = self.get_url_stats(ijson)
        elif 2 == cmd_id:
            import project_company_mgmt as pyf
            pObj = pyf.PC_mgmg()
            res = pObj.rm_user_filter_read_project_comapny_mgmt(ijson)
            #res = pObj.read_project_comapny_mgmt(ijson)
        elif 3 == cmd_id:
Exemple #5
0
import os

from flask import Flask
from flask import jsonify
from flask import render_template
from flask import request

import checker
import config
import modules

assert __name__ == '__main__'

proxy_pool_modules = modules.Modules(modules.get_args())

app = Flask('proxy_pool', static_folder='static', static_url_path='/static')


@app.route('/')
def index():
    return render_template('index.html')


@app.route('/logs')
@app.route('/logs/<string:fn>')
def get_logs(fn=''):
    fn = os.path.join(config.LOG_PATH, os.path.basename(fn))
    if os.path.isfile(fn) and fn.endswith('.log'):
        with open(fn) as f:
            return '\n'.join(map('<p>{}</p>'.format, f.readlines()))
    logs = sorted(os.listdir(config.LOG_PATH))
Exemple #6
0
 def __init__(self):
     cmd.Cmd.__init__(self)
     self.prompt = '(vulScan) > '
     self.doc_header = 'Commands'
     self.modules = modules.Modules(self)
Exemple #7
0
def command_start(message):
    modules.Modules(message).cmd_start()