kmisc 2.1.94__tar.gz → 2.1.95__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {kmisc-2.1.94 → kmisc-2.1.95}/PKG-INFO +1 -1
- {kmisc-2.1.94 → kmisc-2.1.95}/kmisc/__init__.py +49 -1
- {kmisc-2.1.94 → kmisc-2.1.95}/kmisc.egg-info/PKG-INFO +1 -1
- {kmisc-2.1.94 → kmisc-2.1.95}/LICENSE +0 -0
- {kmisc-2.1.94 → kmisc-2.1.95}/README.md +0 -0
- {kmisc-2.1.94 → kmisc-2.1.95}/kmisc.egg-info/SOURCES.txt +0 -0
- {kmisc-2.1.94 → kmisc-2.1.95}/kmisc.egg-info/dependency_links.txt +0 -0
- {kmisc-2.1.94 → kmisc-2.1.95}/kmisc.egg-info/top_level.txt +0 -0
- {kmisc-2.1.94 → kmisc-2.1.95}/pyproject.toml +0 -0
- {kmisc-2.1.94 → kmisc-2.1.95}/setup.cfg +0 -0
- {kmisc-2.1.94 → kmisc-2.1.95}/setup.py +0 -0
@@ -15,6 +15,7 @@ import copy
|
|
15
15
|
import json
|
16
16
|
import random
|
17
17
|
import string
|
18
|
+
import socket
|
18
19
|
import pickle
|
19
20
|
import base64
|
20
21
|
import hashlib
|
@@ -47,6 +48,8 @@ except:
|
|
47
48
|
print('Can not install kmport')
|
48
49
|
os._exit(1)
|
49
50
|
|
51
|
+
Import('import whois',install_name='python-whois')
|
52
|
+
#Import('import whois') # it print some comment on screen
|
50
53
|
|
51
54
|
global krc_define
|
52
55
|
global printf_log_base
|
@@ -1473,6 +1476,51 @@ class COLOR:
|
|
1473
1476
|
msg=fmt_msg % (color_code,msg)
|
1474
1477
|
return msg+reset
|
1475
1478
|
|
1479
|
+
def Domainname(source=None,info=False):
|
1480
|
+
if source:
|
1481
|
+
try:
|
1482
|
+
d=whois.whois(source) # python-whois
|
1483
|
+
# d=whois.query(source) # use whois
|
1484
|
+
except Exception:
|
1485
|
+
return False,source
|
1486
|
+
else:
|
1487
|
+
# if info:
|
1488
|
+
# if d is None: return False,None
|
1489
|
+
# return True,d.__dict__
|
1490
|
+
# if d is None: return False,source
|
1491
|
+
# return d.expiration_date >= datetime.now(),source # whois
|
1492
|
+
return bool(d.domain_name),source # python-whois
|
1493
|
+
else:
|
1494
|
+
dn=socket.getfqdn().split('.', 1)
|
1495
|
+
if len(dn) == 1:
|
1496
|
+
return True,dn[0]
|
1497
|
+
else:
|
1498
|
+
return True,dn[1]
|
1499
|
+
|
1500
|
+
def EmailAddress(email,local=False,check_domain=True):
|
1501
|
+
if isinstance(email,str):
|
1502
|
+
src_a=email.split('@')
|
1503
|
+
if not local and len(src_a) == 2:
|
1504
|
+
if len(src_a[0]) > 1 and len(src_a[1]) > 3 and '.' in src_a[1]:
|
1505
|
+
if check_domain is True:
|
1506
|
+
username=src_a[0]
|
1507
|
+
domain=src_a[1]
|
1508
|
+
if Domainname(domain)[0]:
|
1509
|
+
return True,email
|
1510
|
+
else:
|
1511
|
+
return True,email
|
1512
|
+
elif local or len(src_a) in [1,2]:
|
1513
|
+
with open('/etc/passwd','r') as f:
|
1514
|
+
pwi=f.read()
|
1515
|
+
user_list=[i.split(':')[0] for i in pwi.split('\n')]
|
1516
|
+
local_domain=Domainname()[1]
|
1517
|
+
if len(src_a) == 2 and src_a[1]:
|
1518
|
+
if local_domain == src_a[1] and src_a[0] in user_list:
|
1519
|
+
return True,email
|
1520
|
+
elif src_a[0] in user_list:
|
1521
|
+
return True,'{}@{}'.format(src_a[0],local_domain)
|
1522
|
+
return False,email
|
1523
|
+
|
1476
1524
|
class EMAIL:
|
1477
1525
|
############################
|
1478
1526
|
# GMAIL Information
|
@@ -1568,7 +1616,7 @@ class EMAIL:
|
|
1568
1616
|
|
1569
1617
|
#def Send(self,sender,receivers,title='Subject',msg='MSG',dbg=False,filename=None,html=False):
|
1570
1618
|
def Send(self,*receivers,**opts):
|
1571
|
-
sender=opts.get('sender',opts.get('from','
|
1619
|
+
sender=opts.get('sender',opts.get('from','admin@localhost'))
|
1572
1620
|
title=opts.get('title',opts.get('subject','Unknown Subject'))
|
1573
1621
|
msg=opts.get('msg',opts.get('body','No body'))
|
1574
1622
|
dbg=opts.get('dbg',False)
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|