|
| 1 | +from datetime import datetime |
| 2 | +import os |
| 3 | + |
| 4 | +from patchwork.step import Step |
| 5 | +from patchwork.steps import BrowserUse |
| 6 | +from typing import Tuple, List |
| 7 | + |
| 8 | +upi_url = "https://10.142.27.8/UPI/login" |
| 9 | +m2p_url = "http://qa-jiocbs.m2pfintech.dev/dashboard/login" |
| 10 | +files: List[Tuple[str, List[str]]] = [("POS Settlement", []), ("IMPS Settlement", []), ("Wallet Transactions", [])] |
| 11 | +end_of_task = "Then leave the rest for the user. Your job is done." |
| 12 | + |
| 13 | + |
| 14 | +browser_use_defaults = dict( |
| 15 | + google_api_key=os.getenv("GOOGLE_API_KEY"), |
| 16 | + generate_gif=True, |
| 17 | + headless=False, |
| 18 | + task_value={}, |
| 19 | +) |
| 20 | + |
| 21 | + |
| 22 | +def create_inputs(task: str, **kwargs): |
| 23 | + cloned_dict = browser_use_defaults.copy() |
| 24 | + cloned_dict.update(**kwargs) |
| 25 | + cloned_dict["task"] = task + "\n" + end_of_task |
| 26 | + return cloned_dict |
| 27 | + |
| 28 | + |
| 29 | +class Temp(Step): |
| 30 | + def run(self): |
| 31 | + date = datetime.now().strftime("%d-%b-%Y") |
| 32 | + os.makedirs(f"tmp/working_files/{date}", exist_ok=True) |
| 33 | + for file_type in ["Raw Data", "Merchant Raw Data", "PSP Raw data"]: |
| 34 | + BrowserUse( |
| 35 | + create_inputs( |
| 36 | + task=f""" |
| 37 | +Go to {upi_url} |
| 38 | +Login using username `9167471523` and password `Patched#1901` |
| 39 | +
|
| 40 | +Click on File Download |
| 41 | +Click on Settlement Files Download |
| 42 | +
|
| 43 | +In From date enter {date}, and in To date enter {date} |
| 44 | +In Cycle Name select All |
| 45 | +Select File Type {file_type} and click on 'File Search'. |
| 46 | +It will give you 10 files. Click on the download button of each file. |
| 47 | +""" |
| 48 | + ) |
| 49 | + ).run() |
| 50 | + |
| 51 | + return {} |
0 commit comments