update: added sms p2p module
This commit is contained in:
parent
0f62f07c97
commit
b2c8794ec8
50 changed files with 3312 additions and 1 deletions
|
|
@ -1 +0,0 @@
|
|||
Subproject commit d1146046c0a222d1c278cda5c8852980d79ddd23
|
||||
2468
SMS-Exchange-Linux-GUI/GUI.py
Executable file
2468
SMS-Exchange-Linux-GUI/GUI.py
Executable file
File diff suppressed because it is too large
Load diff
21
SMS-Exchange-Linux-GUI/README.md
Executable file
21
SMS-Exchange-Linux-GUI/README.md
Executable file
|
|
@ -0,0 +1,21 @@
|
|||
# Step 1. clone it.
|
||||
```bash
|
||||
git clone https://git.simplifiedprivacy.com/Support/SMS-Exchange-Linux-GUI.git
|
||||
```
|
||||
<br/>
|
||||
|
||||
# Step 2. Setup venv
|
||||
```bash
|
||||
python3 -m venv venv
|
||||
source venv/bin/activate
|
||||
```
|
||||
|
||||
# Step 3. Install Prereqs
|
||||
```bash
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
|
||||
# Step 4. Run it
|
||||
```bash
|
||||
python3 GUI.py
|
||||
```
|
||||
17
SMS-Exchange-Linux-GUI/SCOPE.md
Executable file
17
SMS-Exchange-Linux-GUI/SCOPE.md
Executable file
|
|
@ -0,0 +1,17 @@
|
|||
# Scope
|
||||
|
||||
## Add with Button
|
||||
To the Left of Enable
|
||||
|
||||
# Process Proxy:
|
||||
Inside 'interact_with_rest_of_app' folder
|
||||
Placing that proxy.json in the correct format in the correct profile folder.
|
||||
|
||||
## Which Profile Used:
|
||||
Inside 'interact_with_rest_of_app' folder
|
||||
Using Core to Return which Profile the User has Up
|
||||
|
||||
## Enable button Enables Proxy.json
|
||||
Possible stack with Tor, or pre-existing Wireguard
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
36
SMS-Exchange-Linux-GUI/api_interaction/get_and_save_json_from_our_api.py
Executable file
36
SMS-Exchange-Linux-GUI/api_interaction/get_and_save_json_from_our_api.py
Executable file
|
|
@ -0,0 +1,36 @@
|
|||
import requests
|
||||
from requests.exceptions import RequestException, Timeout, ConnectionError, HTTPError
|
||||
|
||||
async def get_and_save_json_from_our_api(file_path_saved):
|
||||
url = 'https://onboard.simplifiedprivacy.net/initial_data'
|
||||
|
||||
try:
|
||||
# Note: this is a GET request, because it has no customer data:
|
||||
response = requests.get(url, timeout=5) # Adding a timeout for better control
|
||||
|
||||
# Check if the request was successful
|
||||
if response.status_code == 200 or response.status_code == 201:
|
||||
# Save the content to a file
|
||||
with open(file_path_saved, 'w', encoding='utf-8') as file:
|
||||
file.write(response.text)
|
||||
print("Saved JSON from API")
|
||||
return "worked"
|
||||
else:
|
||||
print(f"Failed to retrieve the page: {response.status_code}")
|
||||
return f"Server Connected But Replied with Error Status Code: {response.status_code}"
|
||||
|
||||
except Timeout:
|
||||
print("The request timed out. Please try again later.")
|
||||
return "The request timed out. Please try again later."
|
||||
|
||||
except ConnectionError:
|
||||
print("Failed to connect to the server. Please check your internet connection.")
|
||||
return "Failed to connect to the server. Please check your internet connection."
|
||||
|
||||
except HTTPError as http_err:
|
||||
print(f"HTTP error occurred: {http_err}")
|
||||
return f"HTTP error occurred: {http_err}"
|
||||
|
||||
except RequestException as req_err:
|
||||
print(f"An error occurred while making the request: {req_err}")
|
||||
return f"An error occurred while making the request: {req_err}"
|
||||
38
SMS-Exchange-Linux-GUI/api_interaction/get_initial_email_data.py
Executable file
38
SMS-Exchange-Linux-GUI/api_interaction/get_initial_email_data.py
Executable file
|
|
@ -0,0 +1,38 @@
|
|||
import requests
|
||||
from requests.exceptions import RequestException, Timeout, ConnectionError, HTTPError
|
||||
|
||||
#from local_data_operations.search_or_setup_json import check_and_create_folder_and_json
|
||||
|
||||
async def get_initial_email_data(file_path_saved):
|
||||
url = 'https://onboard.simplifiedprivacy.net/initial_email_data'
|
||||
|
||||
try:
|
||||
# Send a GET request to the URL
|
||||
response = requests.get(url, timeout=5) # Adding a timeout for better control
|
||||
|
||||
# Check if the request was successful
|
||||
if response.status_code == 200 or response.status_code == 201:
|
||||
# Save the content to a file
|
||||
with open(file_path_saved, 'w', encoding='utf-8') as file:
|
||||
file.write(response.text)
|
||||
print("Saved JSON from API")
|
||||
return "worked"
|
||||
else:
|
||||
print(f"Failed to retrieve the page: {response.status_code}")
|
||||
return f"Server Connected But Replied with Error Status Code: {response.status_code}"
|
||||
|
||||
except Timeout:
|
||||
print("The request timed out. Please try again later.")
|
||||
return "The request timed out. Please try again later."
|
||||
|
||||
except ConnectionError:
|
||||
print("Failed to connect to the server. Please check your internet connection.")
|
||||
return "Failed to connect to the server. Please check your internet connection."
|
||||
|
||||
except HTTPError as http_err:
|
||||
print(f"HTTP error occurred: {http_err}")
|
||||
return f"HTTP error occurred: {http_err}"
|
||||
|
||||
except RequestException as req_err:
|
||||
print(f"An error occurred while making the request: {req_err}")
|
||||
return f"An error occurred while making the request: {req_err}"
|
||||
113
SMS-Exchange-Linux-GUI/api_interaction/send_data_to_flask.py
Executable file
113
SMS-Exchange-Linux-GUI/api_interaction/send_data_to_flask.py
Executable file
|
|
@ -0,0 +1,113 @@
|
|||
import aiohttp
|
||||
from aiohttp import ClientConnectorError, ClientResponseError
|
||||
import asyncio
|
||||
import json
|
||||
import sys
|
||||
|
||||
async def send_data_to_flask(chosen_payment_method, chosen_location, chosen_service_as_string, chosen_email_operator, chosen_proxy_status, peer_to_peer_billing_id):
|
||||
async with aiohttp.ClientSession() as session:
|
||||
# filter out if no email:
|
||||
if chosen_email_operator == "email disabled" or chosen_email_operator == "profile already has an email":
|
||||
chosen_email_operator = "disabled"
|
||||
# send to API regardless:
|
||||
try:
|
||||
async with session.post('https://onboard.simplifiedprivacy.net/api', json={
|
||||
'peer_to_peer_billing_id': peer_to_peer_billing_id,
|
||||
'chosen_payment_method': chosen_payment_method,
|
||||
'chosen_service': chosen_service_as_string,
|
||||
'chosen_email': chosen_email_operator,
|
||||
'chosen_proxy_status': chosen_proxy_status,
|
||||
'chosen_location': chosen_location
|
||||
}) as response:
|
||||
content_type = response.headers.get('Content-Type', '')
|
||||
|
||||
if 'application/json' in content_type:
|
||||
return await response.json()
|
||||
else:
|
||||
# If content type is HTML, return the text content
|
||||
html_content = await response.text()
|
||||
return {"error": f"It returned this as HTML: {content_type}, Content: {html_content}"}
|
||||
except ClientConnectorError as e:
|
||||
print(f"Connection error: {e}") # DNS failure, server is down, etc.
|
||||
return {"error": "Connection error: Unable to reach the server"}
|
||||
except ClientResponseError as e:
|
||||
print(f"Response error: {e}") # e.g., 4xx or 5xx responses
|
||||
return {"error": f"Bad response: {e.status} - {e.message}"}
|
||||
|
||||
async def dispute_send_data_to_flask(how_did_it_go, peer_to_peer_billing_id):
|
||||
async with aiohttp.ClientSession() as session:
|
||||
try:
|
||||
async with session.post('https://onboard.simplifiedprivacy.net/dispute', json={
|
||||
'peer_to_peer_billing_id': peer_to_peer_billing_id,
|
||||
'dispute_status': f"{how_did_it_go}"
|
||||
}) as response:
|
||||
return await response.json() # Assuming the server returns JSON
|
||||
|
||||
except ClientConnectorError as e:
|
||||
print(f"Connection error: {e}") # DNS failure, server is down, etc.
|
||||
return {"error": "Connection error: Unable to reach the server"}
|
||||
except ClientResponseError as e:
|
||||
print(f"Response error: {e}") # e.g., 4xx or 5xx responses
|
||||
return {"error": f"Bad response: {e.status} - {e.message}"}
|
||||
|
||||
async def check_if_paid_by_sending_data_to_flask(peer_to_peer_billing_id):
|
||||
async with aiohttp.ClientSession() as session:
|
||||
try:
|
||||
async with session.post('https://onboard.simplifiedprivacy.net/checkpaid', json={
|
||||
'peer_to_peer_billing_id':peer_to_peer_billing_id
|
||||
}) as response:
|
||||
return await response.json() # Assuming the server returns JSON
|
||||
|
||||
except ClientConnectorError as e:
|
||||
print(f"Connection error: {e}") # DNS failure, server is down, etc.
|
||||
return {"error": "Connection error: Unable to reach the server"}
|
||||
except ClientResponseError as e:
|
||||
print(f"Response error: {e}") # e.g., 4xx or 5xx responses
|
||||
return {"error": f"Bad response: {e.status} - {e.message}"}
|
||||
|
||||
async def ready_for_code_by_sending_data_to_flask(peer_to_peer_billing_id):
|
||||
async with aiohttp.ClientSession() as session:
|
||||
try:
|
||||
async with session.post('https://onboard.simplifiedprivacy.net/code', json={
|
||||
'peer_to_peer_billing_id': peer_to_peer_billing_id
|
||||
}) as response:
|
||||
return await response.json() # Assuming the server returns JSON
|
||||
|
||||
except ClientConnectorError as e:
|
||||
print(f"Connection error: {e}") # DNS failure, server is down, etc.
|
||||
return {"error": "Connection error: Unable to reach the server"}
|
||||
except ClientResponseError as e:
|
||||
print(f"Response error: {e}") # e.g., 4xx or 5xx responses
|
||||
return {"error": f"Bad response: {e.status} - {e.message}"}
|
||||
|
||||
async def send_crypto_address_for_refund(peer_to_peer_billing_id, refund_crypto_address):
|
||||
async with aiohttp.ClientSession() as session:
|
||||
try:
|
||||
async with session.post('https://onboard.simplifiedprivacy.net/refund_address', json={
|
||||
'peer_to_peer_billing_id': peer_to_peer_billing_id,
|
||||
'refund_crypto_address': refund_crypto_address
|
||||
}) as response:
|
||||
return await response.json() # Assuming the server returns JSON
|
||||
|
||||
except ClientConnectorError as e:
|
||||
print(f"Connection error: {e}") # DNS failure, server is down, etc.
|
||||
return {"error": "Connection error: Unable to reach the server"}
|
||||
except ClientResponseError as e:
|
||||
print(f"Response error: {e}") # e.g., 4xx or 5xx responses
|
||||
return {"error": f"Bad response: {e.status} - {e.message}"}
|
||||
|
||||
|
||||
async def restore_an_already_finalized_number(peer_to_peer_billing_id, which_stage):
|
||||
async with aiohttp.ClientSession() as session:
|
||||
try:
|
||||
async with session.post(f'https://onboard.simplifiedprivacy.net/{which_stage}', json={
|
||||
'peer_to_peer_billing_id': peer_to_peer_billing_id
|
||||
}) as response:
|
||||
return await response.json() # Assuming the server returns JSON
|
||||
|
||||
except ClientConnectorError as e:
|
||||
print(f"Connection error: {e}") # DNS failure, server is down, etc.
|
||||
return {"error": "Connection error: Unable to reach the server"}
|
||||
except ClientResponseError as e:
|
||||
print(f"Response error: {e}") # e.g., 4xx or 5xx responses
|
||||
return {"error": f"Bad response: {e.status} - {e.message}"}
|
||||
14
SMS-Exchange-Linux-GUI/api_interaction/should_api_be_triggered.py
Executable file
14
SMS-Exchange-Linux-GUI/api_interaction/should_api_be_triggered.py
Executable file
|
|
@ -0,0 +1,14 @@
|
|||
import os
|
||||
import time
|
||||
|
||||
def should_api_be_triggered(file_path, period_of_time):
|
||||
try:
|
||||
# Get the last modification time of the file
|
||||
modification_time = os.path.getmtime(file_path)
|
||||
# Get the current time
|
||||
current_time = time.time()
|
||||
# Check if the file has been modified in the last hour (3600 seconds)
|
||||
return (current_time - modification_time) <= period_of_time
|
||||
except FileNotFoundError:
|
||||
print("File not found.")
|
||||
return False
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
42
SMS-Exchange-Linux-GUI/interact_with_rest_of_app/process_the_proxy.py
Executable file
42
SMS-Exchange-Linux-GUI/interact_with_rest_of_app/process_the_proxy.py
Executable file
|
|
@ -0,0 +1,42 @@
|
|||
import os
|
||||
import json
|
||||
from core.Constants import Constants
|
||||
import interact_with_rest_of_app.which_profile_is_being_used as which_profile_module
|
||||
|
||||
current_profile_number = which_profile_module.which_profile_is_being_used()
|
||||
|
||||
print('the current profile number is: ', current_profile_number)
|
||||
print('the path is: ', Constants.HV_PROFILE_CONFIG_HOME)
|
||||
|
||||
|
||||
def process_the_proxy(returned_data_as_a_dictionary):
|
||||
proxy_ip_address_in_GUI = returned_data_as_a_dictionary.get(
|
||||
'proxy_ip_address')
|
||||
proxy_password_in_GUI = returned_data_as_a_dictionary.get('proxy_password')
|
||||
proxy_username_in_GUI = returned_data_as_a_dictionary.get('proxy_username')
|
||||
try:
|
||||
proxy_port_in_GUI = int(
|
||||
returned_data_as_a_dictionary.get('proxy_port'))
|
||||
except (ValueError, TypeError):
|
||||
proxy_port_in_GUI = 1080
|
||||
|
||||
# Create a new dictionary:
|
||||
new_formatted_dictonary_to_write_to_folder = {
|
||||
"ip_address": proxy_ip_address_in_GUI,
|
||||
"port_number": proxy_port_in_GUI,
|
||||
"username": proxy_username_in_GUI,
|
||||
"password": proxy_password_in_GUI,
|
||||
"time_zone": "America/New_York"
|
||||
}
|
||||
|
||||
current_profile_number = which_profile_module.which_profile_is_being_used()
|
||||
print('the current profile number is: ', current_profile_number)
|
||||
custom_path = f'{Constants.HV_PROFILE_CONFIG_HOME}/{current_profile_number}/proxyTEST.json'
|
||||
|
||||
# Ensure the directory exists
|
||||
os.makedirs(os.path.dirname(custom_path), exist_ok=True)
|
||||
|
||||
# Write the dictionary to a JSON file at the custom path
|
||||
with open(custom_path, 'w') as json_file:
|
||||
json.dump(new_formatted_dictonary_to_write_to_folder,
|
||||
json_file, indent=4)
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
import sys
|
||||
|
||||
if len(sys.argv) > 1:
|
||||
try:
|
||||
print('the profile id is: ', sys.argv[1])
|
||||
assigned_profile_id = int(sys.argv[1])
|
||||
except ValueError:
|
||||
print('Error: Profile ID must be an integer.')
|
||||
sys.exit(1)
|
||||
else:
|
||||
print('Error: No profile ID provided.')
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
def which_profile_is_being_used():
|
||||
if len(sys.argv) > 1:
|
||||
try:
|
||||
print('the profile id is: ', sys.argv[1])
|
||||
return int(sys.argv[1])
|
||||
except ValueError:
|
||||
print('Error: Profile ID must be an integer.')
|
||||
sys.exit(1)
|
||||
else:
|
||||
print('Error: No profile ID provided.')
|
||||
sys.exit(1)
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -0,0 +1,16 @@
|
|||
import random
|
||||
|
||||
def generate_random_number_string(length=10):
|
||||
numbers = ''.join(random.choice('0123456789') for _ in range(length))
|
||||
# Insert dashes every 4 digits
|
||||
formatted_string = '_'.join(numbers[i:i+4] for i in range(0, length, 4))
|
||||
final_seller_string = f"BUYER3_{formatted_string}"
|
||||
return final_seller_string
|
||||
|
||||
# Generate and print the random number string
|
||||
#i = 0
|
||||
#while i < 5:
|
||||
# print(generate_random_number_string())
|
||||
# i = i +1
|
||||
|
||||
|
||||
54
SMS-Exchange-Linux-GUI/local_data_operations/load_or_setup_config.py
Executable file
54
SMS-Exchange-Linux-GUI/local_data_operations/load_or_setup_config.py
Executable file
|
|
@ -0,0 +1,54 @@
|
|||
from local_data_operations.search_or_setup_json import get_the_path_of_the_folder_for, load_json_as_dict, replace_and_save_value_in_json
|
||||
import json
|
||||
import os
|
||||
|
||||
def get_default_config():
|
||||
default_json_content = {
|
||||
"error_log_file_path": "error_log_for_gui.txt",
|
||||
"local_data": True,
|
||||
"default_currency": False,
|
||||
"turn_off_email_option": False,
|
||||
"turn_off_proxy_option": False,
|
||||
"cache_available": True,
|
||||
}
|
||||
return default_json_content
|
||||
|
||||
def load_or_setup_local_api_data_folder():
|
||||
path_for_data = get_the_path_of_the_folder_for('.local/share', 'api_data')
|
||||
|
||||
# Check if the folder exists
|
||||
if not os.path.exists(path_for_data):
|
||||
# Create the folder if it doesn't exist
|
||||
os.makedirs(path_for_data)
|
||||
print(f"Folder '{path_for_data}' created.")
|
||||
else:
|
||||
print(f"Folder '{path_for_data}' already exists.")
|
||||
|
||||
return path_for_data
|
||||
|
||||
def load_or_setup_config(json_file_name):
|
||||
# setup configs file:
|
||||
path_for_configs = get_the_path_of_the_folder_for('.config', 'sms')
|
||||
|
||||
default_json_content = get_default_config()
|
||||
|
||||
raw_data = load_json_as_dict(path_for_configs, json_file_name, default_json_content)
|
||||
|
||||
# Return data in searchable format:
|
||||
return raw_data
|
||||
|
||||
# for the initial jsons from the API:
|
||||
def setup_path_to_dump_initial_api_data(filename):
|
||||
path_for_configs = get_the_path_of_the_folder_for('.config', 'api_data')
|
||||
final_file_path = f"{path_for_configs}/{filename}"
|
||||
return final_file_path
|
||||
|
||||
def replace_config_value(json_file_name, key_value_to_find, value_to_replace):
|
||||
# setup configs file:
|
||||
path_for_configs = get_the_path_of_the_folder_for('.config', 'sms')
|
||||
|
||||
default_json_content = get_default_config()
|
||||
|
||||
new_data_set = replace_and_save_value_in_json(path_for_configs, json_file_name, default_json_content, key_value_to_find, value_to_replace)
|
||||
|
||||
return new_data_set
|
||||
290
SMS-Exchange-Linux-GUI/local_data_operations/local_logs.py
Executable file
290
SMS-Exchange-Linux-GUI/local_data_operations/local_logs.py
Executable file
|
|
@ -0,0 +1,290 @@
|
|||
from interact_with_rest_of_app.which_profile_is_being_used import which_profile_is_being_used
|
||||
|
||||
# Loading and using JSONs
|
||||
from local_data_operations.search_or_setup_json import get_the_path_of_the_folder_for, load_json_as_dict, search_key_in_json
|
||||
|
||||
# Generic:
|
||||
import json
|
||||
import os
|
||||
|
||||
def return_profile_filename_and_path(product):
|
||||
# filename:
|
||||
current_profile_number = which_profile_is_being_used()
|
||||
if product == "email":
|
||||
json_file_name = f"email_{current_profile_number}.json"
|
||||
else: # this is sms:
|
||||
json_file_name = f"{current_profile_number}.json"
|
||||
|
||||
# folder path:
|
||||
path_for_configs = get_the_path_of_the_folder_for('.config', 'sms')
|
||||
|
||||
# full path:
|
||||
# Check if the folder exists
|
||||
if not os.path.exists(path_for_configs):
|
||||
# Create the folder if it doesn't exist
|
||||
os.makedirs(path_for_configs)
|
||||
print(f"Folder '{path_for_configs}' created.")
|
||||
else:
|
||||
print(f"Folder '{path_for_configs}' already existed.")
|
||||
|
||||
# Full path for the JSON file
|
||||
full_json_file_path = os.path.join(path_for_configs, json_file_name)
|
||||
|
||||
return json_file_name, path_for_configs, full_json_file_path
|
||||
|
||||
def check_if_profile_exists_already(full_json_file_path):
|
||||
# Check if the JSON file exists
|
||||
if os.path.exists(full_json_file_path):
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
# When a profile is initiated, we want to know if it has a country and proxy already assigned.
|
||||
def get_profile_location_and_proxy_status_as_tuple():
|
||||
# get the path and other variables that are not needed, but have to be unpacked:
|
||||
json_file_name, path_for_configs, full_json_file_path = return_profile_filename_and_path("sms")
|
||||
|
||||
# Check if the JSON file exists:
|
||||
if os.path.exists(full_json_file_path):
|
||||
# if so get the data:
|
||||
with open(full_json_file_path, 'r') as json_file:
|
||||
data = json.load(json_file)
|
||||
|
||||
# get the location, or return "none" if it can't be found.
|
||||
# return json_dict.get(key, default_value_if_not_found)
|
||||
assigned_location = data.get("profile", {}).get("location", False)
|
||||
assigned_proxy = data.get("profile", {}).get("assigned_proxy", False)
|
||||
if assigned_location == "":
|
||||
return False
|
||||
else:
|
||||
return (assigned_location, assigned_proxy)
|
||||
else:
|
||||
return False
|
||||
|
||||
# If it does not exist already, then create it from scratch: # darth vadar
|
||||
def setup_email_config(email_operator, full_email, email_password, email_url):
|
||||
print("SETUP EMAIL CONFIG triggered")
|
||||
email_json_file_name, path_for_configs, email_full_json_file_path = return_profile_filename_and_path("email")
|
||||
# Add the email data:
|
||||
new_data = {
|
||||
"email_operator": email_operator,
|
||||
"full_email": full_email,
|
||||
"email_url": email_url,
|
||||
"email_password": email_password
|
||||
}
|
||||
|
||||
try:
|
||||
# Update the JSON Profile with new data:
|
||||
with open(email_full_json_file_path, 'w') as json_file:
|
||||
json.dump(new_data, json_file, indent=4)
|
||||
return True # it worked:
|
||||
except:
|
||||
return "error"
|
||||
|
||||
def wipe_entire_profile_data():
|
||||
json_file_name, path_for_configs, full_json_file_path = return_profile_filename_and_path("sms")
|
||||
# Check if the file exists
|
||||
if os.path.isfile(full_json_file_path):
|
||||
# Delete the file
|
||||
os.remove(full_json_file_path)
|
||||
print(f"{full_json_file_path} has been deleted.")
|
||||
return True
|
||||
else:
|
||||
print(f"{full_json_file_path} does not exist.")
|
||||
return False
|
||||
|
||||
|
||||
def wipe_email_data():
|
||||
email_json_file_name, path_for_configs, email_full_json_file_path = return_profile_filename_and_path("email")
|
||||
# Check if the file exists
|
||||
if os.path.isfile(email_full_json_file_path):
|
||||
# Delete the file
|
||||
os.remove(email_full_json_file_path)
|
||||
print(f"{email_full_json_file_path} has been deleted.")
|
||||
return True
|
||||
else:
|
||||
print(f"{email_full_json_file_path} does not exist.")
|
||||
return False
|
||||
|
||||
def get_email_data():
|
||||
print("READ EMAIL CONFIG triggered")
|
||||
email_json_file_name, path_for_configs, email_full_json_file_path = return_profile_filename_and_path("email")
|
||||
# Check if the JSON file exists
|
||||
if os.path.exists(email_full_json_file_path):
|
||||
try:
|
||||
with open(email_full_json_file_path, 'r') as json_file:
|
||||
email_data = json.load(json_file)
|
||||
email_operator = email_data['email_operator']
|
||||
full_email = email_data['full_email']
|
||||
email_url = email_data['email_url']
|
||||
email_password = email_data['email_password']
|
||||
packed_email_data = (email_operator, full_email, email_url, email_password)
|
||||
return packed_email_data
|
||||
except:
|
||||
return "error"
|
||||
else:
|
||||
return False
|
||||
|
||||
def wipe_location_and_proxy():
|
||||
# then get the profile number & path:
|
||||
json_file_name, path_for_configs, full_json_file_path = return_profile_filename_and_path("sms")
|
||||
|
||||
if os.path.exists(full_json_file_path):
|
||||
# if so get the data:
|
||||
with open(full_json_file_path, 'r') as json_file:
|
||||
data = json.load(json_file)
|
||||
|
||||
# clear it:
|
||||
data['profile']['location'] = ""
|
||||
data['profile']['assigned_proxy'] = False
|
||||
try:
|
||||
# Update the JSON Profile with new data:
|
||||
with open(full_json_file_path, 'w') as json_file:
|
||||
json.dump(data, json_file, indent=4)
|
||||
return True # it worked:
|
||||
except:
|
||||
return "error"
|
||||
|
||||
# if it does NOT exist:
|
||||
else:
|
||||
return True
|
||||
|
||||
|
||||
# If it does not exist already, then create it from scratch:
|
||||
def create_or_add_to_profile_config(config_file_data, peer_to_peer_billing_id, chosen_location, proxy_or_not, chosen_service, email_operator):
|
||||
# first check if the user disabled local data saving in the config file:
|
||||
do_we_want_logs = search_key_in_json(config_file_data, "local_data", True)
|
||||
if do_we_want_logs == False:
|
||||
return False
|
||||
else:
|
||||
# then get the profile number & path:
|
||||
json_file_name, path_for_configs, full_json_file_path = return_profile_filename_and_path("sms")
|
||||
|
||||
if os.path.exists(full_json_file_path):
|
||||
# if so get the data:
|
||||
with open(full_json_file_path, 'r') as json_file:
|
||||
data = json.load(json_file)
|
||||
|
||||
# If it's a blank location, then update it with the new choices:
|
||||
pre_existing_location = data['profile']['location']
|
||||
if pre_existing_location == "":
|
||||
data['profile']['location'] = chosen_location
|
||||
data['profile']['assigned_proxy'] = proxy_or_not
|
||||
else:
|
||||
pass
|
||||
|
||||
# Add the new order:
|
||||
data["orders"][peer_to_peer_billing_id] = {
|
||||
"chosen_service": chosen_service,
|
||||
"wants_sms": True,
|
||||
"completed": False
|
||||
}
|
||||
|
||||
try:
|
||||
# Update the JSON Profile with new data:
|
||||
with open(full_json_file_path, 'w') as json_file:
|
||||
json.dump(data, json_file, indent=4)
|
||||
return True # it worked:
|
||||
#updated_json = json.dumps(data, indent=4)
|
||||
except:
|
||||
return "error"
|
||||
|
||||
# if it does NOT exist:
|
||||
else:
|
||||
# We are creating a new Profile Config:
|
||||
|
||||
# stock the JSON with values for a new profile:
|
||||
default_json_content = {
|
||||
"profile": {
|
||||
"location": chosen_location,
|
||||
"assigned_proxy": proxy_or_not,
|
||||
"got_proxy": False,
|
||||
"email_operator": email_operator
|
||||
},
|
||||
"orders": {
|
||||
peer_to_peer_billing_id: {
|
||||
"chosen_service": chosen_service,
|
||||
"wants_sms": True,
|
||||
"completed": False
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try:
|
||||
# Create the JSON file:
|
||||
with open(full_json_file_path, 'w') as json_file:
|
||||
json.dump(default_json_content, json_file, indent=4)
|
||||
return True # it worked:
|
||||
except:
|
||||
return "error"
|
||||
|
||||
|
||||
|
||||
def return_all_locally_saved_orders_for_the_current_profile():
|
||||
# get the path and other variables that are not needed, but have to be unpacked:
|
||||
json_file_name, path_for_configs, full_json_file_path = return_profile_filename_and_path("sms")
|
||||
|
||||
# Check if the JSON file exists:
|
||||
if os.path.exists(full_json_file_path):
|
||||
# setup a list to save the orders:
|
||||
list_of_all_past_orders = []
|
||||
|
||||
try:
|
||||
# if so get the data:
|
||||
with open(full_json_file_path, 'r') as json_file:
|
||||
data = json.load(json_file)
|
||||
|
||||
# Iterate through the orders & get their past details:
|
||||
for order in data["orders"]:
|
||||
chosen_service = data["orders"][order]["chosen_service"]
|
||||
completed = data["orders"][order]["completed"]
|
||||
order_data_as_tuple = (order, chosen_service, completed)
|
||||
list_of_all_past_orders.append(order_data_as_tuple)
|
||||
except:
|
||||
return False
|
||||
finally:
|
||||
return list_of_all_past_orders
|
||||
else:
|
||||
return False
|
||||
|
||||
|
||||
|
||||
def delete_an_order(which_order):
|
||||
# get the profile number & path:
|
||||
json_file_name, path_for_configs, full_json_file_path = return_profile_filename_and_path("sms")
|
||||
|
||||
if os.path.exists(full_json_file_path):
|
||||
# if so get the data:
|
||||
with open(full_json_file_path, 'r') as json_file:
|
||||
data = json.load(json_file)
|
||||
|
||||
try:
|
||||
# delete it:
|
||||
del data["orders"][which_order]
|
||||
|
||||
# Update the JSON Profile with new data:
|
||||
with open(full_json_file_path, 'w') as json_file:
|
||||
json.dump(data, json_file, indent=4)
|
||||
return True # it worked
|
||||
except:
|
||||
return "error"
|
||||
|
||||
'''
|
||||
# see if email operator is blank even though they have one from the past:
|
||||
if email_operator == None:
|
||||
# then get the profile number & path:
|
||||
json_file_name, path_for_configs, full_json_file_path = return_profile_filename_and_path("sms")
|
||||
try:
|
||||
with open(full_json_file_path, 'r') as json_file:
|
||||
data = json_file.load(json_file)
|
||||
email_operator = data[profile][email_operator]
|
||||
except:
|
||||
email_operator = None
|
||||
'''
|
||||
|
||||
#email_operator = None
|
||||
#full_email = "test@t.com"
|
||||
#email_password = "dd"
|
||||
#email_url = "aa.com"
|
||||
#config_file_data = "a"
|
||||
#setup_email_config(config_file_data, email_operator, full_email, email_password, email_url)
|
||||
74
SMS-Exchange-Linux-GUI/local_data_operations/search_or_setup_json.py
Executable file
74
SMS-Exchange-Linux-GUI/local_data_operations/search_or_setup_json.py
Executable file
|
|
@ -0,0 +1,74 @@
|
|||
import os
|
||||
import json
|
||||
|
||||
def check_and_create_folder_and_json(folder_path, json_file_name, default_json_content):
|
||||
# Check if the folder exists
|
||||
if not os.path.exists(folder_path):
|
||||
# Create the folder if it doesn't exist
|
||||
os.makedirs(folder_path)
|
||||
print(f"Folder '{folder_path}' created.")
|
||||
else:
|
||||
print(f"Folder '{folder_path}' already exists.")
|
||||
|
||||
# Full path for the JSON file
|
||||
json_file_path = os.path.join(folder_path, json_file_name)
|
||||
|
||||
# Check if the JSON file exists
|
||||
if not os.path.exists(json_file_path):
|
||||
# If it doesn't exist, then create the JSON file with "hello world"
|
||||
with open(json_file_path, 'w') as json_file:
|
||||
json.dump(default_json_content, json_file, indent=4)
|
||||
print(f"JSON file '{json_file_name}' created with content: {{'message': 'hello world'}}.")
|
||||
else:
|
||||
print(f"JSON file '{json_file_name}' already exists in '{folder_path}'.")
|
||||
|
||||
## Load JSON file and return it as a dictionary.
|
||||
def load_json_as_dict(folder_path, json_file_name, default_json_content):
|
||||
full_path_with_filename = f"{folder_path}/{json_file_name}"
|
||||
if not os.path.exists(full_path_with_filename):
|
||||
print(f"JSON file '{full_path_with_filename}' does not exist yet. So the program is now making it")
|
||||
check_and_create_folder_and_json(folder_path, json_file_name, default_json_content)
|
||||
|
||||
# Regardless of it was just made or not, load it,
|
||||
with open(full_path_with_filename, 'r') as json_file:
|
||||
data = json.load(json_file)
|
||||
return data
|
||||
|
||||
## Search for a key in the dictionary and return its value or a message if not found.
|
||||
def search_key_in_json(json_dict, key, default_value_if_not_found):
|
||||
return json_dict.get(key, default_value_if_not_found)
|
||||
|
||||
def get_the_path_of_the_folder_for(which_folder_type, subfolder_name):
|
||||
HOME = os.path.expanduser('~') # Get the user's home directory
|
||||
config_path = os.path.join(HOME, which_folder_type) # Create a path to the .config directory
|
||||
path_for_configs = f"{config_path}/sms-exchange/{subfolder_name}"
|
||||
return path_for_configs
|
||||
|
||||
|
||||
def replace_and_save_value_in_json(folder_path, json_file_name, default_json_content, key_value_to_find, value_to_replace):
|
||||
# Check if the folder exists
|
||||
if not os.path.exists(folder_path):
|
||||
# Create the folder if it doesn't exist
|
||||
os.makedirs(folder_path)
|
||||
|
||||
# Full path for the JSON file
|
||||
json_file_path = os.path.join(folder_path, json_file_name)
|
||||
|
||||
# Check if the JSON file exists,
|
||||
if os.path.exists(json_file_path):
|
||||
# and if so then load it:
|
||||
with open(json_file_path, 'r') as json_file:
|
||||
data = json.load(json_file)
|
||||
else:
|
||||
# otherwise use the default values:
|
||||
data = json.load(json_file_path)
|
||||
|
||||
# Replace the value of the key "key_value_to_find" with "value_to_replace"
|
||||
data[key_value_to_find] = value_to_replace
|
||||
|
||||
# Now write the entire thing into the JSON file:
|
||||
with open(json_file_path, 'w') as json_file:
|
||||
json.dump(data, json_file, indent=4)
|
||||
|
||||
return data
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
13
SMS-Exchange-Linux-GUI/process_api_data/convert_to_dictonary.py
Executable file
13
SMS-Exchange-Linux-GUI/process_api_data/convert_to_dictonary.py
Executable file
|
|
@ -0,0 +1,13 @@
|
|||
import json
|
||||
|
||||
def search_by_category(category, data):
|
||||
# Initialize an empty list to hold matching items
|
||||
matching_items = []
|
||||
for entry in data:
|
||||
# Check if the category matches
|
||||
if category in entry.values():
|
||||
matching_items.append(entry)
|
||||
|
||||
# Convert dictonary of results into a list:
|
||||
list_of_matching_items = [list(d.keys())[0] for d in matching_items]
|
||||
return list_of_matching_items
|
||||
31
SMS-Exchange-Linux-GUI/process_api_data/extract_a_list_of_values.py
Executable file
31
SMS-Exchange-Linux-GUI/process_api_data/extract_a_list_of_values.py
Executable file
|
|
@ -0,0 +1,31 @@
|
|||
import json
|
||||
|
||||
def extract_a_list_of_values(json_list, what_to_look_for):
|
||||
# Convert the list to a JSON string
|
||||
json_string = json.dumps(json_list)
|
||||
|
||||
# Convert the JSON string back to a list of dictionaries
|
||||
data = json.loads(json_string)
|
||||
|
||||
result = []
|
||||
for item in data:
|
||||
if isinstance(item, dict):
|
||||
#print(f"checking this item {item}")
|
||||
if item.get('type') == what_to_look_for:
|
||||
result.append(item.get('what'))
|
||||
return result
|
||||
|
||||
|
||||
def get_the_locations_for_a_service(json_list, what_to_look_for):
|
||||
# Convert the list to a JSON string
|
||||
json_string = json.dumps(json_list)
|
||||
|
||||
# Convert the JSON string back to a list of dictionaries
|
||||
data = json.loads(json_string)
|
||||
|
||||
result = []
|
||||
for item in data:
|
||||
if isinstance(item, dict):
|
||||
if item.get('what') == what_to_look_for:
|
||||
return item.get('locations', ["monkey"])
|
||||
|
||||
18
SMS-Exchange-Linux-GUI/process_api_data/read_from_text_file_into_list.py
Executable file
18
SMS-Exchange-Linux-GUI/process_api_data/read_from_text_file_into_list.py
Executable file
|
|
@ -0,0 +1,18 @@
|
|||
# Specify the path to your text file
|
||||
#file_path = 'Buyer_Client_for_phone_number/list_of_services.txt'
|
||||
|
||||
def read_from_text_file_into_list(file_path):
|
||||
|
||||
# Initialize an empty list to store the strings
|
||||
string_list = []
|
||||
|
||||
# Open the file and read the contents
|
||||
with open(file_path, 'r') as file:
|
||||
# Read the entire content of the file
|
||||
content = file.read()
|
||||
|
||||
# Split the content by ', ' and strip single quotes from each item
|
||||
string_list = [item.strip().strip("'") for item in content.split(',')]
|
||||
|
||||
# Return the resulting list
|
||||
return string_list
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
10
SMS-Exchange-Linux-GUI/process_email_data/filter_email_names.py
Executable file
10
SMS-Exchange-Linux-GUI/process_email_data/filter_email_names.py
Executable file
|
|
@ -0,0 +1,10 @@
|
|||
# Convert it to lowercase and replace spaces with underscores to prevent SQL injections:
|
||||
def filter_email_names(uppercase_chosen_email):
|
||||
lowercase_raw_email = uppercase_chosen_email.lower()
|
||||
|
||||
if lowercase_raw_email == "random email operator":
|
||||
return "random"
|
||||
if lowercase_raw_email == "no email" or lowercase_raw_email == "email disabled":
|
||||
return "no"
|
||||
else:
|
||||
return lowercase_raw_email.replace(" ", "_")
|
||||
13
SMS-Exchange-Linux-GUI/process_email_data/load_email_operators.py
Executable file
13
SMS-Exchange-Linux-GUI/process_email_data/load_email_operators.py
Executable file
|
|
@ -0,0 +1,13 @@
|
|||
import json
|
||||
|
||||
def load_email_operators(path_to_email_operators_list):
|
||||
try:
|
||||
with open(path_to_email_operators_list, 'r') as json_file:
|
||||
data = json.load(json_file)
|
||||
return data
|
||||
except FileNotFoundError as e:
|
||||
print(f"Error: {e}")
|
||||
except json.JSONDecodeError as e:
|
||||
print(f"Invalid JSON: {e}")
|
||||
except Exception as e:
|
||||
print(f"An error occurred: {e}")
|
||||
19
SMS-Exchange-Linux-GUI/requirements.txt
Executable file
19
SMS-Exchange-Linux-GUI/requirements.txt
Executable file
|
|
@ -0,0 +1,19 @@
|
|||
aiohappyeyeballs==2.6.1
|
||||
aiohttp==3.13.3
|
||||
aiosignal==1.4.0
|
||||
asyncio==4.0.0
|
||||
attrs==25.4.0
|
||||
certifi==2026.1.4
|
||||
charset-normalizer==3.4.4
|
||||
frozenlist==1.8.0
|
||||
idna==3.11
|
||||
multidict==6.7.0
|
||||
propcache==0.4.1
|
||||
PyQt6==6.10.2
|
||||
PyQt6-Qt6==6.10.1
|
||||
PyQt6_sip==13.11.0
|
||||
qasync==0.28.0
|
||||
requests==2.32.5
|
||||
typing_extensions==4.15.0
|
||||
urllib3==2.6.3
|
||||
yarl==1.22.0
|
||||
Loading…
Reference in a new issue