diff --git a/.idea/misc.xml b/.idea/misc.xml
index 985be2b..f715034 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,4 +1,4 @@
-
+
\ No newline at end of file
diff --git a/.idea/monitor.iml b/.idea/monitor.iml
index 74d515a..95c5a10 100644
--- a/.idea/monitor.iml
+++ b/.idea/monitor.iml
@@ -4,7 +4,7 @@
-
+
\ No newline at end of file
diff --git a/__pycache__/monitor.cpython-39.pyc b/__pycache__/monitor.cpython-39.pyc
index ba3f0ba..5ee189c 100644
Binary files a/__pycache__/monitor.cpython-39.pyc and b/__pycache__/monitor.cpython-39.pyc differ
diff --git a/cache/record.txt b/cache/record.txt
index 8d9edee..2255a1e 100644
--- a/cache/record.txt
+++ b/cache/record.txt
@@ -3,4 +3,42 @@
2023-08-05 16:18:39
2023-08-05 16:35:21
2023-08-05 16:51:34
-2023-08-05 17:03:17
\ No newline at end of file
+2023-08-05 17:03:17
+2023-08-05 17:22:21
+2023-08-05 17:27:49
+2023-08-05 17:33:23
+2023-08-05 17:41:28
+2023-08-05 17:45:57
+2023-08-05 17:50:16
+2023-08-05 17:57:55
+2023-08-05 18:03:01
+2023-08-07 12:06:32
+2023-08-07 12:54:44
+2023-08-07 13:08:40
+2023-08-07 13:13:34
+2023-08-07 13:22:38
+2023-08-07 13:33:59
+2023-08-07 13:44:37
+2023-08-07 13:51:41
+2023-08-07 13:58:42
+2023-08-07 14:06:02
+2023-08-07 14:36:10
+2023-08-07 07:45:09
+2023-08-07 08:19:47
+2023-08-07 08:25:04
+2023-08-07 08:38:54
+2023-08-07 08:45:01
+2023-08-07 08:49:49
+2023-08-07 08:55:08
+2023-08-07 09:00:53
+2023-08-07 09:05:36
+2023-08-07 09:10:41
+2023-08-07 09:18:31
+2023-08-07 09:26:42
+2023-08-07 09:35:38
+2023-08-07 09:40:33
+2023-08-07 09:52:47
+2023-08-07 09:59:44
+2023-08-07 10:07:50
+2023-08-07 10:14:39
+2023-08-07 10:20:43
\ No newline at end of file
diff --git a/config.ini b/config.ini
index 3c9edae..503bbda 100644
--- a/config.ini
+++ b/config.ini
@@ -1,8 +1,9 @@
[Cache]
cache_file_path = cache/record.txt
-
-
+[General]
+#timedifference成功拿取任务和现在的时间差,大于此时间差重启ProxyMe
+time_difference = 1800
[Database]
host = 192.168.2.20
diff --git a/error_devices.txt b/error_devices.txt
index e69de29..947e8b4 100644
--- a/error_devices.txt
+++ b/error_devices.txt
@@ -0,0 +1,6 @@
+
+8AGX0SMQF
+8AGX0SMQF
+8AGX0SMQF
+8AGX0SMQF
+8AGX0SMQF
\ No newline at end of file
diff --git a/main.py b/main.py
index 8ac1cd7..916369e 100644
--- a/main.py
+++ b/main.py
@@ -44,6 +44,6 @@ if __name__ == '__main__':
except KeyboardInterrupt:
pass
-
+#
# if __name__ == '__main__':
# main()
\ No newline at end of file
diff --git a/modules/__pycache__/command.cpython-39.pyc b/modules/__pycache__/command.cpython-39.pyc
index ce71cd2..663e04b 100644
Binary files a/modules/__pycache__/command.cpython-39.pyc and b/modules/__pycache__/command.cpython-39.pyc differ
diff --git a/modules/command.py b/modules/command.py
index 8561d57..0d52aa1 100644
--- a/modules/command.py
+++ b/modules/command.py
@@ -11,12 +11,12 @@ def run_adb_command(command_list):
def get_now_time(device):
# adb shell date +%s
- output, status_code, error = run_adb_command(['adb', '-s', device, 'shell', 'date', '+%s'])
+ output, status_code, error = run_adb_command(['adb', '-s', device, 'shell', 'date',"'+%Y-%m-%d %H:%M:%S'"])
if status_code == 0:
print(f"get_now_time output: {output}")
logging.info(f"get now time output: {output}")
- now_timestamp = int(output)
- return now_timestamp
+ now_time = output
+ return now_time
else:
print(error)
logging.error(f"get now time error: {error}")
@@ -100,4 +100,5 @@ def restart_ProxyMe(device):
return False
else:
print(f"stop autojs failed")
- return False
\ No newline at end of file
+ return False
+
diff --git a/modules/read_config.py b/modules/read_config.py
index d4534e9..8ad5c05 100644
--- a/modules/read_config.py
+++ b/modules/read_config.py
@@ -16,3 +16,9 @@ def read_config_ini():
# return cache_file_path,database_config
return cache_file_path
+def read_time_difference():
+ file_path = './config.ini'
+ config = configparser.ConfigParser()
+ config.read(file_path)
+ time_difference = config.get("General","time_difference")
+ return time_difference
\ No newline at end of file
diff --git a/monitor.py b/monitor.py
index 818996b..f017f99 100644
--- a/monitor.py
+++ b/monitor.py
@@ -1,9 +1,10 @@
import logging
-
+import pytz
import modules.fileRW
from datetime import datetime
import modules.device
import modules.command
+import modules.read_config
def convert_to_timestamp(string_time):
# 定义日期时间格式
date_format = "%Y-%m-%d %H:%M:%S"
@@ -39,10 +40,23 @@ def get_last_time():
return None
+def str_to_timestamp(time_str):
+ format_str = "%Y-%m-%d %H:%M:%S"
+ try:
+ dt_object = datetime.strptime(time_str,format_str)
+ timestamp = dt_object.timestamp()
+ return timestamp
+ except ValueError as e:
+ logging.error(f"str_to_timestamp error: {e}")
+ print("Error:", e)
+ return None
+
+
+
def adb_get_now_time(device):
- now_timestamp = modules.command.get_now_time(device)
- if now_timestamp != None:
- convert_timestamp(now_timestamp)
+ now_time = modules.command.get_now_time(device)
+ if now_time != None:
+ now_timestamp = str_to_timestamp(now_time)
return now_timestamp
else:
return None
@@ -56,14 +70,15 @@ def monitor(device):
diff_timestamp = now_timestamp - last_line_timestamp
print(f"diff_timestamp: {diff_timestamp},与上次成功获取任务时间差{int(diff_timestamp/60)}分钟")
logging.info(f"{device}与上次成功获取任务时间差{int(diff_timestamp/60)}分钟")
- if diff_timestamp >= 1800:
+ time_difference = modules.read_config.read_time_difference()
+ if diff_timestamp >= time_difference:
success = modules.command.restart_ProxyMe(device)
if success:
return True
else:
return False
else:
- print(f"时间差小于40分钟,不执行重启ProxyMe")
+ print(f"时间差小于{time_difference}分钟,不执行重启ProxyMe")
return True
else:
print(f"get now timestamp: failed")
diff --git a/test.py b/test.py
new file mode 100644
index 0000000..71314e4
--- /dev/null
+++ b/test.py
@@ -0,0 +1,22 @@
+from datetime import datetime
+
+
+def format_time_string(input_time_str):
+ try:
+ # 解析时区时间字符串为datetime对象
+ dt_object = datetime.strptime(input_time_str, "%a %b %d %H:%M:%S %Z %Y")
+
+ # 将datetime对象重新格式化为所需的字符串格式
+ formatted_time_str = dt_object.strftime("%Y-%m-%d %H:%M:%S")
+
+ return formatted_time_str
+ except ValueError as e:
+ print("Error: Invalid time format.")
+ return None
+
+
+# 测试函数
+input_time_str = "Mon Aug 7 09:33:39 BST 2023"
+formatted_time = format_time_string(input_time_str)
+if formatted_time is not None:
+ print(formatted_time)