Example #1
0
class NamecoinAddress(metaclass=Object):
    name = "Namecoin address"
    namecoint_address = Attribute("Namecoin address", ValueType.String)
    namecoint_address_short = Attribute("Namecoin address (short)", ValueType.String)
    IdentAttrs = [namecoint_address]
    CaptionAttrs = [namecoint_address_short]
    # some changes
    if exists_file(r"images\namecoin.png"):
        Image = Utils.base64string(r"images\namecoin.png")
    else:
        try:
            Image = requests.get(f"http://{SERVER_RESOURCE}/objects/ico/{namecoin_icon}", timeout=3).text
        except:
            pass
Example #2
0
class NamecoinTXid(metaclass=Object):
    name = "Namecoin transaction"
    txid = Attribute("Transaction id", ValueType.String)
    txid_short = Attribute("Transaction id (short)", ValueType.String)
    IdentAttrs = [txid]
    CaptionAttrs = [txid_short]
    # some changes
    if exists_file(r"images\TX.png"):
        Image = Utils.base64string(r"images\TX.png")
    else:
        try:
            Image = requests.get(f"http://{SERVER_RESOURCE}/objects/ico/{tx_icon}", timeout=3).text
        except:
            pass
Example #3
0
def _create_engine(path_db, type_db):
    """Создание объекта-движка для определённой БД"""
    # TODO возможны различные тонкости при подключении к базам данных
    # TODO указание драйвера
    db_mark = ''
    if type_db == 'SQLite' or type_db == 1:
        if not exists_file(path_db):
            raise FileNotFoundError(
                'По принятому пути не существует БД SQLite: ' + str(path_db))
        db_mark = r'sqlite:///'
    elif type_db == 'MS SQL Server' or type_db == 2:
        pass
    else:
        raise ValueError('Неподдерживаемая СУБД: ' + str(type_db))
    return create_engine(db_mark + path_db, echo=False)
Example #4
0
def execjs_encode(item):
    """execute js function and need modify code"""
    # please add local js file path or remote internet js address
    string_js = ''''''
    local_js_path = ""
    remote_js_url = "http://www.example.com/js/somefunction.js"

    resource = ""
    global js_cache
    import traceback
    if js_cache:
        resource = js_cache
    elif string_js:
        resource = string_js
    elif local_js_path:
        from os.path import isfile as exists_file
        if exists_file(local_js_path):
            with open(local_js_path, 'r') as f:
                resource = f.read()
    else:
        try:
            from urllib.request import urlopen
        except:
            from urllib2 import urlopen
        finally:
            try:
                resource = urlopen(remote_js_url).read()
            except:
                print("[-] occurred error:")
                exit(traceback.print_exc())
    if not js_cache:
        try:
            import execjs
        except ImportError:
            exit("[-] please: pip install pyexecjs")
        finally:
            js_cache = resource
    exec_compile = execjs.compile(resource.decode('utf8'))
    try:
        return exec_compile.call('fun_name', item, "parm1", "parm2_if_need")
    except:
        print("[-] occurred error:")
        exit(traceback.print_exc())