Don't use sys.exit(), re-raise ImportError instead

This commit is contained in:
Dan 2018-03-26 03:39:30 +02:00
parent ae21ada0f4
commit 42a2878842
2 changed files with 8 additions and 8 deletions

View File

@ -18,17 +18,18 @@
import logging
import socket
import sys
from collections import namedtuple
try:
import socks
except ImportError:
sys.exit(
except ImportError as e:
e.msg = (
"PySocks is missing and Pyrogram can't run without. "
"Please install it using \"pip3 install pysocks\"."
)
raise e
log = logging.getLogger(__name__)
Proxy = namedtuple("Proxy", ["enabled", "hostname", "port", "username", "password"])

View File

@ -16,19 +16,18 @@
# You should have received a copy of the GNU Lesser General Public License
# along with Pyrogram. If not, see <http://www.gnu.org/licenses/>.
import sys
try:
import tgcrypto
except ImportError:
sys.exit(
except ImportError as e:
e.msg = (
"TgCrypto is missing and Pyrogram can't run without. "
"Please install it using \"pip3 install tgcrypto\". "
"More info: https://docs.pyrogram.ml/resources/TgCrypto"
)
raise e
# TODO: Ugly IFs
class AES:
@classmethod
def ige_encrypt(cls, data: bytes, key: bytes, iv: bytes) -> bytes: