forked from dashingsoft/pyarmor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfoo.py
More file actions
68 lines (54 loc) · 1.71 KB
/
foo.py
File metadata and controls
68 lines (54 loc) · 1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import os
import sys
import pytransform
#-----------------------------------------------------------
#
# Part 1: check internet time by ntp server
#
#-----------------------------------------------------------
def check_expired_date_by_ntp():
from ntplib import NTPClient
from time import mktime, strptime
NTP_SERVER = 'europe.pool.ntp.org'
EXPIRED_DATE = '20190202'
print('The license will be expired on %s' % EXPIRED_DATE)
print('Check internet time from %s ...' % NTP_SERVER)
c = NTPClient()
response = c.request(NTP_SERVER, version=3)
if response.tx_time > mktime(strptime(EXPIRED_DATE, '%Y%m%d')):
print("The license has been expired")
sys.exit(1)
print("The license is not expired")
#-----------------------------------------------------------
#
# Part 2: show license information of obfuscated scripts
#
#-----------------------------------------------------------
def show_left_days_of_license():
try:
rcode = pytransform.get_license_info()['CODE']
left_days = pytransform.get_expired_days()
if left_days == -1:
print('This license for %s is never expired' % rcode)
else:
print('This license for %s will be expired in %d days' % \
(rcode, left_days))
except Exception as e:
print(e)
sys.exit(1)
#-----------------------------------------------------------
#
# Part 3: business code
#
#-----------------------------------------------------------
def hello():
print('Hello world!')
def sum2(a, b):
return a + b
def main():
hello()
print('1 + 1 = %d' % sum2(1, 1))
if __name__ == '__main__':
show_left_days_of_license()
# check_expired_date_by_ntp()
main()