daily pastebin goal
65%
SHARE
TWEET

Python import libs

a guest Mar 25th, 2019 60 in 19 hours
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import os, sys, subprocess
  2.  
  3. def importLibs(module, name):
  4.     module = __import__(module, fromlist=[name])
  5.     return getattr(module, name)
  6.  
  7. def checkRequirements():
  8.     try:
  9.         from Crypto import AES
  10.     except ImportError as ie:
  11.         print(ie)
  12.         try:
  13.             subprocess.call("pip install --user pycryptodome", shell=True)
  14.             importLibs('Crypto.Cypher', 'AES')
  15.         except subprocess.CalledProcessError as cpe:
  16.             print(cpe)
  17.         except OSError as oe:
  18.             print(oe)
  19.  
  20.     try:
  21.         importLibs('Crypto.Random', 'get_random_bytes')
  22.     except ImportError as ie:
  23.         print(ie)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top