403Webshell
Server IP : 103.119.228.120  /  Your IP : 3.15.17.60
Web Server : Apache
System : Linux v8.techscape8.com 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64
User : nobody ( 99)
PHP Version : 5.6.40
Disable Function : shell_exec,symlink,system,exec,proc_get_status,proc_nice,proc_terminate,define_syslog_variables,syslog,openlog,closelog,escapeshellcmd,passthru,ocinum cols,ini_alter,leak,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dl,dll,myshellexec,proc_open,socket_bind,proc_close,escapeshellarg,parse_ini_filepopen,fpassthru,exec,passthru,escapeshellarg,escapeshellcmd,proc_close,proc_open,ini_alter,popen,show_source,proc_nice,proc_terminate,proc_get_status,proc_close,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,dl,symlink,shell_exec,system,dl,passthru,escapeshellarg,escapeshellcmd,myshellexec,c99_buff_prepare,c99_sess_put,fpassthru,getdisfunc,fx29exec,fx29exec2,is_windows,disp_freespace,fx29sh_getupdate,fx29_buff_prepare,fx29_sess_put,fx29shexit,fx29fsearch,fx29ftpbrutecheck,fx29sh_tools,fx29sh_about,milw0rm,imagez,sh_name,myshellexec,checkproxyhost,dosyayicek,c99_buff_prepare,c99_sess_put,c99getsource,c99sh_getupdate,c99fsearch,c99shexit,view_perms,posix_getpwuid,posix_getgrgid,posix_kill,parse_perms,parsesort,view_perms_color,set_encoder_input,ls_setcheckboxall,ls_reverse_all,rsg_read,rsg_glob,selfURL,dispsecinfo,unix2DosTime,addFile,system,get_users,view_size,DirFiles,DirFilesWide,DirPrintHTMLHeaders,GetFilesTotal,GetTitles,GetTimeTotal,GetMatchesCount,GetFileMatchesCount,GetResultFiles,fs_copy_dir,fs_copy_obj,fs_move_dir,fs_move_obj,fs_rmdir,SearchText,getmicrotime
MySQL : ON |  cURL : ON |  WGET : ON |  Perl : ON |  Python : ON |  Sudo : ON |  Pkexec : ON
Directory :  /lib/mysqlsh/lib/python3.9/site-packages/setuptools/tests/integration/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /lib/mysqlsh/lib/python3.9/site-packages/setuptools/tests/integration/helpers.py
"""Reusable functions and classes for different types of integration tests.

For example ``Archive`` can be used to check the contents of distribution built
with setuptools, and ``run`` will always try to be as verbose as possible to
facilitate debugging.
"""

import os
import subprocess
import tarfile
from pathlib import Path
from zipfile import ZipFile


def run(cmd, env=None):
    r = subprocess.run(
        cmd,
        capture_output=True,
        text=True,
        encoding="utf-8",
        env={**os.environ, **(env or {})},
        # ^-- allow overwriting instead of discarding the current env
    )

    out = r.stdout + "\n" + r.stderr
    # pytest omits stdout/err by default, if the test fails they help debugging
    print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
    print(f"Command: {cmd}\nreturn code: {r.returncode}\n\n{out}")

    if r.returncode == 0:
        return out
    raise subprocess.CalledProcessError(r.returncode, cmd, r.stdout, r.stderr)


class Archive:
    """Compatibility layer for ZipFile/Info and TarFile/Info"""

    def __init__(self, filename):
        self._filename = filename
        if filename.endswith("tar.gz"):
            self._obj = tarfile.open(filename, "r:gz")
        elif filename.endswith("zip"):
            self._obj = ZipFile(filename)
        else:
            raise ValueError(f"{filename} doesn't seem to be a zip or tar.gz")

    def __iter__(self):
        if hasattr(self._obj, "infolist"):
            return iter(self._obj.infolist())
        return iter(self._obj)

    def get_name(self, zip_or_tar_info):
        if hasattr(zip_or_tar_info, "filename"):
            return zip_or_tar_info.filename
        return zip_or_tar_info.name

    def get_content(self, zip_or_tar_info):
        if hasattr(self._obj, "extractfile"):
            content = self._obj.extractfile(zip_or_tar_info)
            if content is None:
                msg = f"Invalid {zip_or_tar_info.name} in {self._filename}"
                raise ValueError(msg)
            return str(content.read(), "utf-8")
        return str(self._obj.read(zip_or_tar_info), "utf-8")


def get_sdist_members(sdist_path):
    with tarfile.open(sdist_path, "r:gz") as tar:
        files = [Path(f) for f in tar.getnames()]
    # remove root folder
    relative_files = ("/".join(f.parts[1:]) for f in files)
    return {f for f in relative_files if f}


def get_wheel_members(wheel_path):
    with ZipFile(wheel_path) as zipfile:
        return set(zipfile.namelist())

Youez - 2016 - github.com/yon3zu
LinuXploit