0.1.21 修复循环调用时软件包的过量统计

This commit is contained in:
guanjihuan 2023-11-07 17:25:44 +08:00
parent 3c0bacd8c8
commit b25f573b20
4 changed files with 37 additions and 32 deletions

View File

@ -1,7 +1,7 @@
[metadata] [metadata]
# replace with your username: # replace with your username:
name = guan name = guan
version = 0.1.20 version = 0.1.21
author = guanjihuan author = guanjihuan
author_email = guanjihuan@163.com author_email = guanjihuan@163.com
description = An open source python package description = An open source python package

View File

@ -1,6 +1,6 @@
Metadata-Version: 2.1 Metadata-Version: 2.1
Name: guan Name: guan
Version: 0.1.20 Version: 0.1.21
Summary: An open source python package Summary: An open source python package
Home-page: https://py.guanjihuan.com Home-page: https://py.guanjihuan.com
Author: guanjihuan Author: guanjihuan

View File

@ -15,6 +15,5 @@ from .file_processing import *
from .data_processing import * from .data_processing import *
import guan import guan
rand_number = guan.get_random_number(start=1, end=10) guan.notification_of_upgrade()
if rand_number == 5: global_variable_of_first_guan_package_calling = True
guan.notification_of_upgrade()

View File

@ -385,24 +385,27 @@ def get_mac_address():
# Guan软件包的使用统计不涉及到用户的个人数据 # Guan软件包的使用统计不涉及到用户的个人数据
def statistics_of_guan_package(): def statistics_of_guan_package():
try: global global_variable_of_first_guan_package_calling
import guan if global_variable_of_first_guan_package_calling == True:
message_calling = guan.get_calling_function_name(layer=3) global_variable_of_first_guan_package_calling = False
if message_calling == '<module>': try:
import socket import guan
datetime_date = guan.get_date() message_calling = guan.get_calling_function_name(layer=3)
datetime_time = guan.get_time() if message_calling == '<module>':
current_version = guan.get_current_version('guan') import socket
client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) datetime_date = guan.get_date()
client_socket.settimeout(0.5) datetime_time = guan.get_time()
client_socket.connect(('py.guanjihuan.com', 12345)) current_version = guan.get_current_version('guan')
mac_address = guan.get_mac_address() client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
message = guan.get_calling_function_name(layer=2) client_socket.settimeout(0.5)
send_message = datetime_date + ' ' + datetime_time + ' version_'+current_version + ' MAC_address: '+mac_address+' guan.' + message+'\n' client_socket.connect(('py.guanjihuan.com', 12345))
client_socket.send(send_message.encode()) mac_address = guan.get_mac_address()
client_socket.close() message = guan.get_calling_function_name(layer=2)
except: send_message = datetime_date + ' ' + datetime_time + ' version_'+current_version + ' MAC_address: '+mac_address+' guan.' + message+'\n'
pass client_socket.send(send_message.encode())
client_socket.close()
except:
pass
# 获取Python软件包的最新版本 # 获取Python软件包的最新版本
def get_latest_version(package_name='guan', timeout=0.5): def get_latest_version(package_name='guan', timeout=0.5):
@ -430,12 +433,15 @@ def get_current_version(package_name='guan'):
# Guan软件包升级提示 # Guan软件包升级提示
def notification_of_upgrade(timeout=0.5): def notification_of_upgrade(timeout=0.5):
try: import guan
import guan rand_number = guan.get_random_number(start=1, end=10)
latest_version = guan.get_latest_version(package_name='guan', timeout=timeout) if rand_number == 5:
current_version = guan.get_current_version('guan') try:
if latest_version != None and current_version != None: import guan
if latest_version != current_version: latest_version = guan.get_latest_version(package_name='guan', timeout=timeout)
print('提示:您当前使用的版本是 guan-'+current_version+',目前已经有最新版本 guan-'+latest_version+'。您可以通过以下命令对软件包进行升级pip install --upgrade guan') current_version = guan.get_current_version('guan')
except: if latest_version != None and current_version != None:
pass if latest_version != current_version:
print('提示:您当前使用的版本是 guan-'+current_version+',目前已经有最新版本 guan-'+latest_version+'。您可以通过以下命令对软件包进行升级pip install --upgrade guan')
except:
pass