0.1.21 修复循环调用时软件包的过量统计
This commit is contained in:
		| @@ -1,6 +1,6 @@ | ||||
| Metadata-Version: 2.1 | ||||
| Name: guan | ||||
| Version: 0.1.20 | ||||
| Version: 0.1.21 | ||||
| Summary: An open source python package | ||||
| Home-page: https://py.guanjihuan.com | ||||
| Author: guanjihuan | ||||
|   | ||||
| @@ -15,6 +15,5 @@ from .file_processing import * | ||||
| from .data_processing import * | ||||
|  | ||||
| import guan | ||||
| rand_number = guan.get_random_number(start=1, end=10) | ||||
| if rand_number == 5: | ||||
|     guan.notification_of_upgrade() | ||||
| guan.notification_of_upgrade() | ||||
| global_variable_of_first_guan_package_calling = True | ||||
| @@ -385,24 +385,27 @@ def get_mac_address(): | ||||
|  | ||||
| # Guan软件包的使用统计(不涉及到用户的个人数据) | ||||
| def statistics_of_guan_package(): | ||||
|     try: | ||||
|         import guan | ||||
|         message_calling = guan.get_calling_function_name(layer=3) | ||||
|         if message_calling == '<module>': | ||||
|             import socket | ||||
|             datetime_date = guan.get_date() | ||||
|             datetime_time = guan.get_time() | ||||
|             current_version = guan.get_current_version('guan') | ||||
|             client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | ||||
|             client_socket.settimeout(0.5) | ||||
|             client_socket.connect(('py.guanjihuan.com', 12345)) | ||||
|             mac_address = guan.get_mac_address() | ||||
|             message = guan.get_calling_function_name(layer=2) | ||||
|             send_message = datetime_date + ' ' + datetime_time + ' version_'+current_version + ' MAC_address: '+mac_address+' guan.' + message+'\n' | ||||
|             client_socket.send(send_message.encode()) | ||||
|             client_socket.close() | ||||
|     except: | ||||
|         pass | ||||
|     global global_variable_of_first_guan_package_calling | ||||
|     if global_variable_of_first_guan_package_calling == True: | ||||
|         global_variable_of_first_guan_package_calling = False | ||||
|         try: | ||||
|             import guan | ||||
|             message_calling = guan.get_calling_function_name(layer=3) | ||||
|             if message_calling == '<module>': | ||||
|                 import socket | ||||
|                 datetime_date = guan.get_date() | ||||
|                 datetime_time = guan.get_time() | ||||
|                 current_version = guan.get_current_version('guan') | ||||
|                 client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | ||||
|                 client_socket.settimeout(0.5) | ||||
|                 client_socket.connect(('py.guanjihuan.com', 12345)) | ||||
|                 mac_address = guan.get_mac_address() | ||||
|                 message = guan.get_calling_function_name(layer=2) | ||||
|                 send_message = datetime_date + ' ' + datetime_time + ' version_'+current_version + ' MAC_address: '+mac_address+' guan.' + message+'\n' | ||||
|                 client_socket.send(send_message.encode()) | ||||
|                 client_socket.close() | ||||
|         except: | ||||
|             pass | ||||
|  | ||||
| # 获取Python软件包的最新版本 | ||||
| def get_latest_version(package_name='guan', timeout=0.5): | ||||
| @@ -430,12 +433,15 @@ def get_current_version(package_name='guan'): | ||||
|  | ||||
| # Guan软件包升级提示 | ||||
| def notification_of_upgrade(timeout=0.5): | ||||
|     try: | ||||
|         import guan | ||||
|         latest_version = guan.get_latest_version(package_name='guan', timeout=timeout) | ||||
|         current_version = guan.get_current_version('guan') | ||||
|         if latest_version != None and current_version != None: | ||||
|             if latest_version != current_version: | ||||
|                 print('提示:您当前使用的版本是 guan-'+current_version+',目前已经有最新版本 guan-'+latest_version+'。您可以通过以下命令对软件包进行升级:pip install --upgrade guan') | ||||
|     except: | ||||
|         pass | ||||
|     import guan | ||||
|     rand_number = guan.get_random_number(start=1, end=10) | ||||
|     if rand_number == 5: | ||||
|         try: | ||||
|             import guan | ||||
|             latest_version = guan.get_latest_version(package_name='guan', timeout=timeout) | ||||
|             current_version = guan.get_current_version('guan') | ||||
|             if latest_version != None and current_version != None: | ||||
|                 if latest_version != current_version: | ||||
|                     print('提示:您当前使用的版本是 guan-'+current_version+',目前已经有最新版本 guan-'+latest_version+'。您可以通过以下命令对软件包进行升级:pip install --upgrade guan') | ||||
|         except: | ||||
|             pass | ||||
		Reference in New Issue
	
	Block a user