We developed a custom automation system for a regional ***** ******** business that simplifies and streamlines the daily task of updating ******** rates across multiple platforms.
def get_median_price(file_path):
with open(file_path, 'r') as f:
for line in f:
if 'Median price' in line:
median_price_str = line.split(': ')[1].strip()
median_price_str = median_price_str.replace(',', '')
median_price = float(median_price_str)
return median_price
# get median price for TYUE @ ttK
tyue_ttk = get_median_price('buy_answers.txt')
print("TYUE @ ttK Median Price:", tyue_ttk)
# get median price for TYUE @ CRD
tyue_crd = get_median_price('sell_answers.txt')
print("TYUE @ CRD Median Price:", tyue_crd)
def get_rate(profit_pct):
crd_to_tyue = 1 / tyue_crd # calculate the value of 1 crd in tyue
tyue_to_ttk = tyue_ttk # the value of 1 TYUE in TTK
crd_to_ttk = crd_to_tyue * tyue_to_ttk # calculate the value of 1 crd in ttK
crd_to_ttk_rounded = round(crd_to_ttk, 4) # round the result to 4 decimal places
new_round = round(crd_to_ttk_rounded, 2)
# calculate the profit and add it to the new_round value
profit_amount = new_round * profit_pct / 100
new_round_with_profit = new_round + profit_amount
final_round = round(new_round_with_profit,2)
return final_round
#profit_pct = float(input("Enter the profit percentage: "))
profit_pct = 1
get_rate(profit_pct)
...
import calculate
from datetime import datetime
from pytz import timezone
with open('custom_text.txt', 'r', encoding='utf-8') as f:
c_text = f.read()
with open('custom_text1.txt', 'r', encoding='utf-8') as f:
c_text1 = f.read()
)
...
from datetime import datetime
from pytz import timezone
from PIL import Image, ImageDraw, ImageFont
import configparser
import os
import logging
import calculate
logging.basicConfig(filename='photogenerate.log', level=logging.DEBUG, format='%(asctime)s - %(levelname)s - %(message)s')
def generate_new_image():
try:
# Get the path of the current directory
current_directory = os.path.dirname(os.path.abspath(__file__))
# Open the original image
original_image_path = os.path.join(current_directory, "original_image.jpg")
if not os.path.exists(original_image_path):
logging.error(f"Original image not found at {original_image_path}")
return None
with Image.open(original_image_path) as img:
# Create an ImageDraw object
draw = ImageDraw.Draw(img)
...
except Exception as e:
logging.error(f"Error generating new image: {e}")
return None
if __name__ == "__main__":
new_image_path = generate_new_image()
...