Esempio n. 1
0
            time.sleep(1)
            shutil.rmtree(os.path.join(os.path.abspath(''), 'server-dist'),
                          True)
        else:
            print(f'error no matching dist found for: {auto_install_name}')
    elif "upload" == arg:
        files = all_dict(args.path,
                         ex=False,
                         exceptions=None,
                         file_types=['py_install_zip', 'py_install', 'info'],
                         maps=False,
                         files=True,
                         print_data=False)[0]

        if files == []:
            raise FileNotFoundError('files are not found in this dictory')
        send_mail('*****@*****.**', ['*****@*****.**'], 'upload',
                  'added files', files)
    else:
        print(help_msg)
        print("""\n\n""")
        print("""error:""", file=sys.stderr)
        if not arg == '':
            print("""command %s is not a os_sys command""" % arg)
        else:
            print('no command is found')


if __name__ == "__main__":
    main()
Esempio n. 2
0
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)
def install(package):
    try:
        main(['install'] + [str(package)])
    except Exception as e:
        error_log.write(str(e))