svhozt commited on
Commit
3c20f1d
·
1 Parent(s): 23457e3

Fix urllib

Browse files
Files changed (1) hide show
  1. gps.py +23 -47
gps.py CHANGED
@@ -2,14 +2,6 @@ import requests
2
  import urllib.parse
3
  import gradio as gr
4
 
5
- # Replace with your actual credentials
6
- USER_ID = "94777895019" # Your phone number in international format
7
- PASSWORD = "9624" # Your 4-digit password
8
-
9
- # Admin credentials for the login page (you can change them)
10
- ADMIN_USERNAME = "admin"
11
- ADMIN_PASSWORD = "1234"
12
-
13
  # List of 20 phone numbers (SIMs) installed in GPS trackers
14
  SIM_NUMBERS = [
15
  "94757271180", "94758339857", "94758529725", "94753670267", "94758620601",
@@ -39,12 +31,12 @@ def remove_processed_imeis(processed_imeis):
39
  return f"Successfully processed and removed {len(processed_imeis)} IMEIs from file."
40
 
41
  # Function to send SMS and check delivery
42
- def send_sms_and_check_delivery(recipient, message):
43
  base_url = "https://www.textit.biz/sendmsg/index.php"
44
  encoded_message = urllib.parse.quote(message) # URL encode the message
45
  params = {
46
- "id": USER_ID,
47
- "pw": PASSWORD,
48
  "to": recipient,
49
  "text": encoded_message
50
  }
@@ -60,7 +52,7 @@ def send_sms_and_check_delivery(recipient, message):
60
  return f"Error sending SMS to {recipient}: {e}"
61
 
62
  # Function to process IMEI update in batches of 20
63
- def process_imei_batches():
64
  imeis = read_imei_file()
65
 
66
  if len(imeis) == 0:
@@ -76,11 +68,11 @@ def process_imei_batches():
76
  processed_imeis = []
77
  for sim, imei in zip(SIM_NUMBERS, batch_imeis):
78
  logs.append(f"\nSending CHECK# command to SIM: {sim}")
79
- if "successfully" in send_sms_and_check_delivery(sim, "CHECK#"):
80
  imei_write_command = f"IMEI,{imei}#"
81
  logs.append(f"Sending IMEI write command: {imei_write_command} to SIM: {sim}")
82
 
83
- if "successfully" in send_sms_and_check_delivery(sim, imei_write_command):
84
  processed_imeis.append(imei)
85
  logs.append(f"IMEI {imei} written successfully to {sim}")
86
  else:
@@ -98,40 +90,24 @@ def process_imei_batches():
98
  return logs
99
 
100
  # Gradio UI function
101
- def start_imei_processing():
102
- logs = process_imei_batches()
 
 
 
103
  return "\n".join(logs)
104
 
105
- # Login function
106
- def login(username, password):
107
- if username == ADMIN_USERNAME and password == ADMIN_PASSWORD:
108
- return gr.update(visible=True), gr.update(visible=False), ""
109
- else:
110
- return gr.update(visible=False), gr.update(visible=True), "Invalid credentials. Try again."
111
-
112
- # Creating Gradio interface with login page
113
- with gr.Blocks() as iface:
114
- gr.Markdown("# GPS Tracker IMEI Writer")
115
- with gr.Tab("Login"):
116
- with gr.Row():
117
- username_input = gr.Textbox(label="Username")
118
- password_input = gr.Textbox(label="Password", type="password")
119
- login_button = gr.Button("Login")
120
-
121
- login_message = gr.Textbox(visible=False)
122
- imei_writer_interface = gr.Interface(
123
- fn=start_imei_processing,
124
- inputs=[],
125
- outputs="text",
126
- visible=False,
127
- title="GPS Tracker IMEI Writer",
128
- description="Click the button below to start processing IMEI numbers."
129
- )
130
-
131
- login_button.click(
132
- fn=login,
133
- inputs=[username_input, password_input],
134
- outputs=[imei_writer_interface, login_message, login_message]
135
- )
136
 
137
  iface.launch(share=True)
 
2
  import urllib.parse
3
  import gradio as gr
4
 
 
 
 
 
 
 
 
 
5
  # List of 20 phone numbers (SIMs) installed in GPS trackers
6
  SIM_NUMBERS = [
7
  "94757271180", "94758339857", "94758529725", "94753670267", "94758620601",
 
31
  return f"Successfully processed and removed {len(processed_imeis)} IMEIs from file."
32
 
33
  # Function to send SMS and check delivery
34
+ def send_sms_and_check_delivery(user_id, password, recipient, message):
35
  base_url = "https://www.textit.biz/sendmsg/index.php"
36
  encoded_message = urllib.parse.quote(message) # URL encode the message
37
  params = {
38
+ "id": user_id,
39
+ "pw": password,
40
  "to": recipient,
41
  "text": encoded_message
42
  }
 
52
  return f"Error sending SMS to {recipient}: {e}"
53
 
54
  # Function to process IMEI update in batches of 20
55
+ def process_imei_batches(user_id, password):
56
  imeis = read_imei_file()
57
 
58
  if len(imeis) == 0:
 
68
  processed_imeis = []
69
  for sim, imei in zip(SIM_NUMBERS, batch_imeis):
70
  logs.append(f"\nSending CHECK# command to SIM: {sim}")
71
+ if "successfully" in send_sms_and_check_delivery(user_id, password, sim, "CHECK#"):
72
  imei_write_command = f"IMEI,{imei}#"
73
  logs.append(f"Sending IMEI write command: {imei_write_command} to SIM: {sim}")
74
 
75
+ if "successfully" in send_sms_and_check_delivery(user_id, password, sim, imei_write_command):
76
  processed_imeis.append(imei)
77
  logs.append(f"IMEI {imei} written successfully to {sim}")
78
  else:
 
90
  return logs
91
 
92
  # Gradio UI function
93
+ def start_imei_processing(user_id, password):
94
+ if not user_id or not password:
95
+ return "Error: Please enter both User ID and Password."
96
+
97
+ logs = process_imei_batches(user_id, password)
98
  return "\n".join(logs)
99
 
100
+ # Gradio interface with input validation
101
+ iface = gr.Interface(
102
+ fn=start_imei_processing,
103
+ inputs=[
104
+ gr.Textbox(label="User ID (Phone Number in International Format)", type="text"),
105
+ gr.Textbox(label="Password (4-digit)", type="password"),
106
+ ],
107
+ outputs="text",
108
+ title="GPS Tracker IMEI Writer",
109
+ description="Enter your User ID and Password to start processing IMEI numbers.",
110
+ live=True
111
+ )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
112
 
113
  iface.launch(share=True)