From b25f573b20ad9fd9d2a7147191bf938c57e74628 Mon Sep 17 00:00:00 2001 From: guanjihuan Date: Tue, 7 Nov 2023 17:25:44 +0800 Subject: [PATCH] =?UTF-8?q?0.1.21=20=E4=BF=AE=E5=A4=8D=E5=BE=AA=E7=8E=AF?= =?UTF-8?q?=E8=B0=83=E7=94=A8=E6=97=B6=E8=BD=AF=E4=BB=B6=E5=8C=85=E7=9A=84?= =?UTF-8?q?=E8=BF=87=E9=87=8F=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PyPI/setup.cfg | 2 +- PyPI/src/guan.egg-info/PKG-INFO | 2 +- PyPI/src/guan/__init__.py | 5 ++- PyPI/src/guan/data_processing.py | 60 ++++++++++++++++++-------------- 4 files changed, 37 insertions(+), 32 deletions(-) diff --git a/PyPI/setup.cfg b/PyPI/setup.cfg index 68a28ce..27fc556 100644 --- a/PyPI/setup.cfg +++ b/PyPI/setup.cfg @@ -1,7 +1,7 @@ [metadata] # replace with your username: name = guan -version = 0.1.20 +version = 0.1.21 author = guanjihuan author_email = guanjihuan@163.com description = An open source python package diff --git a/PyPI/src/guan.egg-info/PKG-INFO b/PyPI/src/guan.egg-info/PKG-INFO index bc5a8ce..683d6ca 100644 --- a/PyPI/src/guan.egg-info/PKG-INFO +++ b/PyPI/src/guan.egg-info/PKG-INFO @@ -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 diff --git a/PyPI/src/guan/__init__.py b/PyPI/src/guan/__init__.py index c15d671..12b0bda 100644 --- a/PyPI/src/guan/__init__.py +++ b/PyPI/src/guan/__init__.py @@ -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() \ No newline at end of file +guan.notification_of_upgrade() +global_variable_of_first_guan_package_calling = True \ No newline at end of file diff --git a/PyPI/src/guan/data_processing.py b/PyPI/src/guan/data_processing.py index eb89c63..c1eb902 100644 --- a/PyPI/src/guan/data_processing.py +++ b/PyPI/src/guan/data_processing.py @@ -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 == '': - 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 == '': + 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 \ No newline at end of file + 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 \ No newline at end of file