import os
import shutil
import time
from watchdog.events import FileSystemEventHandler
from watchdog.observers import Observer
class EventHandler(FileSystemEventHandler):
def __init__(self, dest_folder):
super().__init__()
self.dest_folder = dest_folder
def on_created(self, event):
print(event.event_type, event.src_path)
print('О новый файл! Я его копирую!')
shutil.copy(event.src_path, self.dest_folder)
if __name__ == "__main__":
src_path = input("Введите путь к исходной папке: ")
dest_path = input("Введите путь к папке назначения: ")
if not os.path.exists(src_path):
print(f"{src_path} не существует.")
exit()
if not os.path.exists(dest_path):
print(f"{dest_path} не существует.")
exit()
event_handler = EventHandler(dest_path)
observer = Observer()
observer.schedule(event_handler, src_path, recursive=True)
observer.start()
observer.join()
api_id = 'your_api_id'
project_id = 'your_project_id'
pay_id = 101
amount = 10.00
currency = 'RUB'
desc = 'Test'
method = 'card'
email = 'r@mail.ru'
api_key = 'your_api_key'
sign = hashlib.sha256(f'create-payment{api_id}{project_id}{pay_id}{amount}{currency}{desc}{method}{api_key}'.encode()).hexdigest()
response = requests.get(f'https://anypay.io/api/create-payment/{api_id}',
params={'project_id': project_id,
'pay_id': pay_id,
'amount': amount,
'currency': currency,
'desc': desc,
'method': method,
'email': email,
'sign': sign})
response_json = json.loads(response.text)
if 'result' in response_json:
url = response_json['result']['payment_url']
print(url)
else:
print(response_json['error'])