Server IP : 172.67.216.182 / Your IP : 172.69.176.156 Web Server : Apache System : Linux krdc-ubuntu-s-2vcpu-4gb-amd-blr1-01.localdomain 5.15.0-142-generic #152-Ubuntu SMP Mon May 19 10:54:31 UTC 2025 x86_64 User : www ( 1000) PHP Version : 7.4.33 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /lib/python3/dist-packages/magic/ |
Upload File : |
from ctypes.util import find_library import ctypes import sys import glob import os.path def _lib_candidates(): yield find_library('magic') if sys.platform == 'darwin': paths = [ '/opt/local/lib', '/usr/local/lib', '/opt/homebrew/lib', ] + glob.glob('/usr/local/Cellar/libmagic/*/lib') for i in paths: yield os.path.join(i, 'libmagic.dylib') elif sys.platform in ('win32', 'cygwin'): prefixes = ['libmagic', 'magic1', 'cygmagic-1', 'libmagic-1', 'msys-magic-1'] for i in prefixes: # find_library searches in %PATH% but not the current directory, # so look for both yield './%s.dll' % (i,) yield find_library(i) elif sys.platform == 'linux': # This is necessary because alpine is bad yield 'libmagic.so.1' def load_lib(): for lib in _lib_candidates(): # find_library returns None when lib not found if lib is None: continue try: return ctypes.CDLL(lib) except OSError: pass else: # It is better to raise an ImportError since we are importing magic module raise ImportError('failed to find libmagic. Check your installation')