def __init__(self, master): #1: Create a builder self.builder = builder = pygubu.Builder() from distutils.sysconfig import get_python_lib as gpl #2: Load an ui file builder.add_from_file(os.path.join(gpl(), 'os_sys', 'test.ui')) #3: Create the widget using a master as parent self.mainwindow = builder.get_object('Frame', master) self.mainwindow def none(): pass callbacks = { 'file': add_file, 'files': add_files, 'folder': add_folder, 'select': save_file, 'close': close, 'read': read, 'con': con, 'conz': conz, 'callback': none } builder.connect_callbacks(callbacks)
def check(): path = str(str(gpl()) + 'os_sys') if os.path.isdir(path): print('\ ========\n\ Warning!\n\ ========\n\ you now installing os_sys on a mac, pc, laptop or something else where os_sys is al ready installed\n\ programs that use this lib while can give errors becuse you are not upgrading the lib on the right way\n\ if you want to upgrade this lib than you need to typ this on cmd:\n\ python -m pip install --upgrade os_sys', file=sys.stderr)
def install(path): print('searching files...', file=sys.stderr) file = all_dict(path)[0][0] print('building...', file=sys.stderr) with open(file) as fh: mystr = str(fh.read()) mystr = mystr.rsplit('##########') print('installing...', file=sys.stderr) for i in mystr: path, data = i.rsplit('>>>>>>>>>>>>>>>') print('prosessing file: %s...' % path, file=sys.stderr) data = str(data) from distutils.sysconfig import get_python_lib as gpl path2 = gpl() with open(os.path.join(path2, path), mode='w+') as kk: kk.write(str(data)) print('done!', file=sys.stderr)
def os_sys_lib(): from distutils.sysconfig import get_python_lib as gpl path = os.path.join(str(gpl()), 'os_sys') return path
z.extractall(temp.split('.')[0]) self.count += 1 z.close() elif temp.endswith('tar') : z=tarfile.open(temp,'r:') z.extractall(temp.split('.')[0]) self.count += 1 z.close() self.extract(temp.split('.')[0]) if self.remove_source_zip: os.remove(temp) except Exception as e: print(temp.split('/')[-1]+' is not a supported file type') extract = Extract from distutils.sysconfig import get_python_lib as gpl path = gpl() osm = [] c_list = [] if __name__ == '__main__': nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0'] for i in os.listdir(path): if 'os_sys' in i: osm.append(i) import string for check in osm: c = string.digits for num in range(0, len(c)): c_list.append(c[num])
def run_(port=8082, host='127.0.0.1', *_files): """choise a port and host to start the server on. if port and host are None the port will be 8082 and the host 127.0.0.1 and the url will be 127.0.0.1:8082""" _f = list(_files) files = {} if port == None: port = 8082 if host == None: host = '127.0.0.1' for item in _f: try: files[item[0]] = item[1] except: files[item[0]] = 'error' import pickle import __main__ as ma global HOST, PORT if __name__ == 'gfhdsuyvsdjhkjgsfsgbhgdfk': return else: HOST, PORT = host, port my_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) my_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) my_socket.bind((HOST, PORT)) my_socket.listen(1) print('Serving on port ', PORT) while True: class r(): def __init__(self): self.GET = {} self.POST = {} req = r() try: # store the original SIGINT handler connection, address = my_socket.accept() except KeyboardInterrupt: print('breaking...') raise SystemExit _request = connection.recv(4096) Request = _request.decode('utf-8') start = Request data = start.split('\n') string_list = Request.split(' ') # Split request from spaces try: requesting_file = string_list[1] except: continue print('Client request ', requesting_file.split('?')[0]) file = requesting_file if isset(files, str(file + '-settings')): settings = files[str(file + '-settings')] assert type(data) == type({}) settings['normal'] = False items_list = [] else: settings = {} settings['normal'] = True try: _POST = data[len(data) - 1] POST = _POST.split('\\n')[-1] except Exception as ex: print('WARNING:', ex) POST = '' else: if POST != '' and POST != []: LIST = POST.split('&') for item in LIST: if item != '': key, data = item.split('=') req.POST[key] = data print('POST: ' + str(req.POST)) myfile = requesting_file.split('?')[ 0] # After the "?" symbol not relevent here if '?' in requesting_file: get = requesting_file.split('?')[1:] get = ''.join(get) get_list = get.split('&') for get_item in get_list: if get_item != '' and '=' in get_item: get_key, get_data = get_item.split('=') req.GET[get_key] = get_data print('GET: ' + str(req.GET)) if (myfile == '/'): myfile = 'index' # Load index file as default ex = None try: try: file = files[myfile] except: try: my = myfile + 'index' file = files[my] except: myfile += '/index' file = files[myfile] response = file(req) codet = 200 name = 'Windows' import platform plat = platform.system() if '<?py' in response and 'py?>' in response: request = req code = response.split('<?py')[1:] for p in code: to_do = p.split('py?>')[0] try: a = exec_return(to_do, request) except Exception as ex: a = 'python internal server error Traceback: %s' % ex codet = 500 print('python:', a) response = response.replace('<?py' + to_do + 'py?>', a, 1) windows = name in plat if '<?php' in response and '?>' in response: import subprocess import os from distutils.sysconfig import get_python_lib as gpl request = req code = response.split('<?php')[1:] php_done = True why = '' if __name__ != 'fg': with open('script.php', 'wb') as file: file.write(str(response).encode('utf-8')) try: if windows: proc = subprocess.Popen(r"%s\php\php script.php" % gpl(), shell=True, stdout=subprocess.PIPE) else: proc = subprocess.Popen( r"%s\php_osx\php\main\php script.php" % gpl(), shell=True, stdout=subprocess.PIPE) a = proc.stdout.read().decode('utf-8') except Exception as ex: codet = 500 print('WARNING:', ex) php_done = False a = '' why = 'WARNING: error while trying to execute php code traceback: %s' % ex if "is not recognized as an internal or external command" in a: codet = 500 a = '' php_done = False if name != plat: why = 'WARNING: php runner only tested on this moment on windows not on %s yet' % plat else: why = 'WARNING: internal server error php can\'t be loaded' if php_done: response = a else: response = response.replace( '<?php' + to_do + '?>', '<script>alert("%s");</script>' % why, 1) php_done = True header = 'HTTP/1.1 200 OK\n' response = response.encode('utf-8') if (myfile.endswith(".jpg")): mimetype = 'image/jpg' elif (myfile.endswith(".css")): mimetype = 'text/css' else: mimetype = 'text/html' header += 'Content-Type: ' + str(mimetype) + '\n\n' except (KeyError, KeyboardInterrupt) as e: print(e) if e == KeyboardInterrupt: raise SystemExit codet = 404 header = 'HTTP/1.1 404 Not Found\n\n' response = '<html><body><center><h3>Error 404: File not found</h3><p>Python HTTP Server</p></center></body></html>'.encode( 'utf-8') except Exception as e: print(e) if e == KeyboardInterrupt: raise SystemExit codet = 500 header = 'HTTP/1.1 500 Internal Server Error\n\n' response = '<html><body><center><h3>Error 500: Internal Server error</h3><p>Python HTTP Server</p></center></body></html>'.encode( 'utf-8') from time import strftime final_response = header.encode('utf-8') final_response += response connection.send(final_response) connection.close() stamp = strftime("%Y-%m-%d %H:%M:%S") code = codet file = requesting_file.split('?')[0] port = PORT host = HOST type_req = string_list[0] print( '[%s] - method: %s - client request: %s - on: %s:%s - status: %s' % (stamp, type_req, file, host, str(port), str(code)))
def install(path, verbose, quiet, _gpl=None): global name if quiet != True: print('searching files...', file=sys.stderr) file = all_dict(path)[0][0] if _gpl == None: from distutils.sysconfig import get_python_lib as gpl else: gpl = _gpl print('reading package files...', file=sys.stderr) with open(file, mode='rb') as fh: mystr = to_str( str( str(str(to_str(fh.read())).replace('\\n', '\n')).replace( '\\r', '\r')).replace('\\n', '')) e = mystr.split('\r') the = all_dict(path, ex=False, exceptions=None, file_types=['py_install_zip'], maps=False, files=True, print_data=False)[0][0] mystr.replace('\n', '') with open( all_dict(path, ex=False, exceptions=None, file_types=['info'], maps=False, files=True, print_data=False)[0][0]) as info: rpackage_info = str(info.read()) package_info = rpackage_info.split('\n') if verbose: print('getting info about package...', file=sys.stderr) info_dict = {} for small in package_info: try: key, value = small.split('=') info_dict[key] = value value = value except: pass else: if 'packages' in key: zipp = eval(value) if 'name' in key: base_path = gpl() + '\\' + value name = value del key, value continue elif key == 'version': version = value del key, value continue else: del key, value continue try: mapsdel = all_dict(gpl() + '\\' + info_dict['name'], maps=True, files=False) except: pass for i in mapsdel: try: _ shutil.rmtree(i) except: pass if quiet != True: print('generating info file...', file=sys.stderr) if isset(info_dict, "include"): try: ok_install = eval(info_dict['include']) except: pass else: from pip.__main__ import _main as main for package in ok_install: package = str(package) try: main(['install', package]) except: try: main(['pip', 'install', package]) except: pass lijst = info_dict['maps'] lijst = str( str( str(str(lijst.replace('[', '')).replace(']', '')).replace( "'", '')).replace('\\\\', '\\')).split(", ") print(info_dict['name']) base = gpl() + '\\' + info_dict['name'] delete = base if os.path.isdir(base): print('found older installation') if quiet != True: print('uninstalling...') try: for i in range(10000): shutil.rmtree(delete, True) _list = all_dict(delete, file_types=None) for i in _list: os.rmdir(i) print('done') except Exception: pass try: os.mkdir(base) except: pass try: os.mkdir(base) os.mkdir(os.path.abspath('\\lib')) except Exception: pass base = base_path for inum in range(0, len(lijst)): i = lijst[inum] print(os.path.join(base, i)) try: os.remove(os.path.join(base, i)) except: pass try: os.makedirs(lijst) except: pass try: os.makedirs(base) except: pass with open(os.path.join(gpl(), info_dict['name'], f'{name}.info'), mode='w+') as done: done.write(rpackage_info) if quiet != True: print('building to temp file...', file=sys.stderr) mystr = mystr.split('##########') tp = tempfile.mkdtemp() import time pbar = tqdm.tqdm(mystr) if time != None: for i in pbar: try: path, data = i.split('>>>>>>>>>>>>>>>') if verbose: pbar.set_description(f'processing file: {path}...') a = path except Exception: pass else: data = str(data) path2 = tp pat = path2 + '\\' + path dir_ = os.path.dirname(pat) try: os.mkdir(dir_) except: pass try: with open(pat, mode='wb') as kk: kk.write( to_bytes( str(str(data).replace('\\r', '\r')).replace( '\\!n', ''))) except Exception: pass pbar.set_description(f'done building!') pbar.close() fik = install_zip(the, base, base, zipp) if quiet != True: print('removing temp dict...', file=sys.stderr) shutil.rmtree(tp, True) print('done!', file=sys.stderr)
""" ChatterBot is a machine learning, conversational dialog engine. default is the default path to the db learning file indev you create a new file so you can see how it works """ from .chatterbot import ChatBot import os from distutils.sysconfig import get_python_lib as gpl path = gpl() default = os.path.join(path, 'chatterbot', 'database.sqlite3') indev = '/database.sqlite3' __all__ = ('ChatBot', 'default', 'indev')
def init(): values = dict( name="os_sys", version="0.9.3",#.dev moet dan hier author="Matthijs labots", contact="python_libs", license='MIT License', contact_email="*****@*****.**", author_email="*****@*****.**", description="a big lib with many usefull tools and it are not only os and sys tools...", long_description='var:long_description', long_description_content_type="text/markdown", url="https://python-libs-com.webnode.nl/", python_requires='>=3', entry_points={'console_scripts': [ 'os_sys-updater = os_sys.commands:update', 'os_sys-download-setup_script = os_sys.commands:download_zip', 'os_sys-if_not_work-write_new_scripts = os_sys.commands:init', 'os_sys-admin = os_sys.commands:run', 'os_sys-re_installer = os_sys.commands:re_install', 'os_sys-run-py_check = os_sys.commands:run_py_check', 'os_sys-admin-run = os_sys.commands:test', 'os_sys-text-editor = os_sys.commands:make_text', 'os_sys-installer = os_sys.commands:install', 'os_sys-easy-installer = os_sys.commands:install', 'os_sys-easy-packages-installer = os_sys.commands:install', 'os_sys-easy-install = os_sys.commands:install', ]}, include_package_data=True, package_data='var:package_data', packages=list(list('var:package_data') + ['os_sys']), install_requires=['progress', 'tqdm', 'progressbar', 'matplotlib', 'numpy', 'jupyter', 'pandas', 'bs4', "Eel", "extract-zip", "text-editor" ], classifiers=[ "Programming Language :: Python :: 3", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", 'Topic :: Software Development :: Libraries :: Python Modules', 'Framework :: IDLE', 'Natural Language :: Dutch', 'Natural Language :: English', "Programming Language :: Python :: 3.0", "Programming Language :: Python :: 3.1", "Programming Language :: Python :: 3.2", "Programming Language :: Python :: 3.3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python", 'Topic :: Internet', 'Topic :: Other/Nonlisted Topic', 'Topic :: Scientific/Engineering :: Mathematics', 'Topic :: Scientific/Engineering :: Visualization', 'Topic :: Software Development :: Build Tools', 'Topic :: Software Development :: User Interfaces', 'Topic :: Software Development', 'Topic :: Scientific/Engineering', 'Development Status :: 4 - Beta', 'Development Status :: 5 - Production/Stable', ], project_urls={ 'all files': 'https://github.com/Matthijs990/os_sys', 'Downloads': 'https://python-libs-com.webnode.nl/downloads/', 'become a member': 'https://python-libs-com.webnode.nl/user-registration/', 'download all files': 'https://github.com/Matthijs990/os_sys.git', 'want to help': 'https://github.com/Matthijs990/os_sys/tree/master/do%20you%20want%20to%20help', 'startpage': 'https://pypi.org/project/os-sys/', 'made possible by': 'https://pypi.org', 'help': 'https://github.com/Matthijs990/os_sys/issues', 'github wiki(under development)': 'https://github.com/Matthijs990/os_sys/wiki', 'just a chat to talk about python': 'https://github.com/Matthijs990/chat/issues/1', 'github': 'https://github.com/Matthijs990/os_sys', 'open os_sys wiki': 'https://python-libs-com.webnode.nl/open-os-sys-wiki/', 'officail wiki(under development)': 'https://python-libs-com.webnode.nl/os-sys-wiki/', 'gitlab': 'https://gitlab.com/Matthijs990/os_sys', }, ) keys = list(values) index = 0 from distutils.sysconfig import get_python_lib as gpl s = open(os.path.join(str(gpl()),'os_sys\setup_values.txt'), 'w+') while index < len(keys): s.write(str(keys[index])+'='+str(values[keys[index]])+'\n') index += 1 s.close() path = os.path.abspath('') print(path) path = path.split('\\') fil = int(len(path) - 1) h = 0 mystr = '' del path[fil] print(path) while h < len(path): mystr = mystr + path[h] mystr = mystr + '\\' h += 1 print(path) print(mystr) index = 0 s = open(os.path.join(str(gpl()), 'os_sys\data_files\settings.config'), 'w+') while index < len(keys): s.write(str(keys[index])+'='+str(values[keys[index]])+'\n') index += 1 s.close() return values del index del s del values del keys
def run(run=True): if run == False: raise SystemExit elif run == True: pass else: raise ValueError('no valid value you typed: %s, its need to be True or False' % run) import setuptools import setuptools as s try: import ready except Exception: pass def execute_from_command_line(argv=None): """Run a ManagementUtility.""" utility = ManagementUtility(argv) utility.execute() package_data = dict() long_description = 'if you try import os_sys and it not work you can try import\ pack that while work then i know the problem and i working on it\ but this is my solution for now thanks\n\n\n' with open("README.md", "r") as fh: long_description.join(fh.read()) import sys import os version = sys.version_info[:2] needing = (3, 3) da = ''.join(str(version[0]) + '.' + str(version[1])) data = dict(version=da, needing=3.3) if version < needing: sys.stderr.write('\ ==========================\n\ Unsupported Python version\n\ ==========================\n\ This version of os_sys requires Python %(needing)s, but you\'re trying to\n\ install it on Python %(version)s\n\ \n\ this is may be becuse you are using a version of pip that doesn\'t\n\ understand the setup script. make shure you\n\ have pip >= 9.0 and setuptools >= 40.0.0, then try again:\n\ \n\ python -m pip install --upgrade pip setuptools\n\ python -m pip install os_sys\n\ \nthis will install the latest version of os_sys\n\n\n' % data) class PythonVersionError(Exception): '''not right python version''' pass raise PythonVersionError('you need at least python 3.3') from distutils.sysconfig import get_python_lib as gpl with open('data_types.txt') as dem: raw_data_types = dem.read() data_types = raw_data_types.split('/') p = data_types overlay_warning = False if "install" in sys.argv: lib_paths = [gpl()] if lib_paths[0].startswith("/usr/lib/"): # We have to try also with an explicit prefix of /usr/local in order to # catch Debian's custom user site-packages directory. lib_paths.append(get_python_lib(prefix="/usr/local")) for lib_path in lib_paths: existing_path = os.path.abspath(os.path.join(lib_path, "os_sys")) if os.path.exists(existing_path): # We note the need for the warning here, but present it after the # command is run, so it's more likely to be seen. overlay_warning = True break re = os.path.abspath def all_maps(d, plus=None): lijst = [os.path.join(d, f) for f in os.listdir(d)] ret = [] num = 0 while num < len(lijst): if '.' in lijst[num]: pass else: if plus == None: ret.append(lijst[num]) else: ret.append(str(plus)+'|'+str(lijst[num])) num += 1 return ret lijst = list(all_maps(os.path.abspath('')) + all_maps(os.path.abspath('os_sys'), plus='os_sys.') + all_maps(os.path.abspath('pack'), plus='pack.')) num = 0 while num < len(lijst): new = str(lijst[num]).split('\\') to = int(len(new) - 1) if '|' in lijst[num]: plus, none = str(lijst[num]).split('|') else: plus = '' if '__pycache__' in new: pass else: package_data.setdefault(plus+new[to], []).extend(p) num += 1 lijst = all_maps(os.path.abspath('os_sys\commands')) print(lijst) num = 0 while num < len(lijst): new = str(lijst[num]).split('\\') to = int(len(new) - 1) if '__pycache__' in new: pass else: package_data.setdefault('os_sys.'+'commands.'+new[to], []).extend(p) if not 'commands' in new[to] else package_data.setdefault('os_sys.'+'commands', []).extend(p) num += 1 print(list(package_data)) long_description = long_description.replace('evry', 'every') print(dict( name="os_sys", version="0.5.2", author="Matthijs labots", author_email="*****@*****.**", description="a big plus lib for more functions to use", long_description_content_type="text/markdown", url="https://python-libs-com.webnode.nl/", python_requires='>=3', entry_points={'console_scripts': [ 'os_sys-updater = os_sys.commands:update', 'download-setup_script = os_sys.commands:download_zip', 'if_not_work-write_new_scripts = os_sys.commands:init', ]}, include_package_data=True, package_data=package_data, packages=['os_sys', 'os_sys.test', 'os_sys.programs', 'os_sys.data_files', 'os_sys.commands', 'os_sys.commands.programs', 'os_sys.commands.data_files', 'os_sys.commands.test', 'pack', 'pack.test', 'pack.programs', 'pack.data_files',], classifiers=[ "Programming Language :: Python :: 3", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", 'Topic :: Software Development :: Libraries :: Python Modules', ], project_urls={ 'all files': 'https://github.com/Matthijs990/os_sys', 'Downloads': 'https://python-libs-com.webnode.nl/downloads/', 'become a member': 'https://python-libs-com.webnode.nl/user-registration/', 'download all files': 'https://github.com/Matthijs990/os_sys.git', 'want to help': 'https://github.com/Matthijs990/os_sys/tree/master/do%20you%20want%20to%20help', 'startpage': 'https://pypi.org/project/os-sys/', 'made possible by': 'https://pypi.org', }, )) print('you need to typ:\n\ from os_sys import os_sys or:\n\ from os_sys import fail or:\n\ from os_sys import system or:\n\ from os_sys import modules or:\n\ from os_sys import wifi or:\n\ from os_sys import *') if overlay_warning: sys.stderr.write('Warning: os_sys is al ready on your pc') init = input('do you want to contact us?(yes or no)') if init.lower() == 'yes': import webbrowser as w w.open('mailto:[email protected]') command = input('do you want to(typ what you want):\n\ download setup script\n\ credits\n\ license\n\ type\n\ all\n\ setup args\n\ None\n\ what you want?:' ) c = command.lower() if c == 'license': with open('license.txt') as fh: data = fh.read() data = data.replace('\\n', '\n') print(data) elif c == 'credits': with open('credits.data') as fh: data = fh.read() data = data.replace('\\n', '\n') print(data) elif c == 'download setup script': download_zip() elif c == 'type': print('python lib') elif c == 'setup args': d = init() print('\n\n\n\n\n') print(d) elif c == 'all': with open('license.txt') as fh: data = fh.read() data = data.replace('\\n', '\n') print(data) with open('credits.data') as fh: data = fh.read() data = data.replace('\\n', '\n') print(data) download_zip() print('python lib') print('\n\n\n\n\n') print(d) elif c == 'None': pass else: raise ValueError('not a right value you typ: %s, but you need to typ:\n\ download setup script\n\ credits\n\ license\n\ type\n\ all\n\ setup args\n\ None' )