software – Files for Court including photos and documents time stamp & date of creation needed on photo or document

I’m in a bit of a bind, I have an Ex-girlfriend (mother of my child) that’s destined to make my life a living hell by withholding my child from me, not following court orders, extremely abusive (verbal and physical) therefore for upcoming court dates, it would be helpful to have a creation date stamped on the photo with as much info as possible such as device it came from, resolution, hell even location etc.

I’m looking for a recommendation for a program that will achieve all of this by convert those documents and photos so I may get them developed on an 5×8 printout and present it as evidence or toss them on a thumb drive.
Yes, I know a time and/or date can be modified (spoofed) if you know what you’re doing although I’m not bothered by that as the effort in doing what i’m trying accomplish may be suffice for my case as some of the documents and pictures are within a short period of time therefore the dates wouldn’t have to be exact as I have 25TB of video footage to date with time stamps and GPS stamps via quality dash cams and hidden body cams as well (can’t take a chance with crazy people)
I just simply need to know which easy to use software that’s designed to do what I’ve mentioned above date/time stamps, IMEI, MAC address or whatever else is possilbe to have extracted from the actual raw file etc.

logging – if the court asks B ISP to find all the people who visit the A site domain among those who use B ISP

However, the operator of Site A refuses to provide visitor logs because they are not nationals of that country.

Can B isp find the IP of everyone who has visited the domain of a site without using a method of looking at the domain visit history of everyone using that isp to see if they have ever visited the site A domain?

legal – Caught speeding 111 Mph (179 km/h) in California. How can I settle the case with the court?

The “speeding in excess of 100mph” charge, CVC 22348(b), is a civil infraction. We do not issue arrest warrants for those. However, failure to appear (CVC 40508) is a crime, and this charge will become that soon.

On the speeding-over-100, you (or your lawyer) do need to face the judge; and that is so they can give you a stern warning, explain the future consequences for doing it again, and make you “scared straight”. (straight is US slang for obeying the law).

Failure to appear = Emergency

Failure to appear, however, is a misdemeanor and will almost certainly result in a warrant for your arrest. This is an actual crime. It may be surprising that a civil infraction turns into a criminal matter if ignored, but that is exactly what happens. Given the language in the letter and the fact that you obviously missed your resolve-it date, that may have already happened.

Heading home without handling this properly is a novice mistake. Your only option now is to hire a lawyer, since you have left the country. Hire one who is local to the court your ticket is in – it should be a lawyer who knows the judges and staff, and isn’t disliked by them. My favorite way to get lawyer referrals is call other nearby lawyers who do not practice in that area of law, and go “I’m sorry, do you know anyone who could help me?” Make 3-4 such calls, you’ll start hearing the same name over and over.

FTA is a new, second charge, so that would be two charges. The upside is this makes it easier to plea-bargain since you now have two things to trade.

How to plead it

All this will happen at arraignment, which is only the initial phase; but given your options it will surely finish here. That is common in traffic matters.

If you had done this sooner, you could have pled not-guilty and asked for a proper trial (which is still a 2-3 minute affair). An order would be issued for the officer to come and testify. Generally if the officer appears, you lose, and if he doesn’t, you’re off scot-free. But you lost that opportunity.

Next you can say you do not wish to plead guilty to 111 mph but would plead guilty to 99 mph, and hope the judge will allow that. The reason to do this is to save a few hundred dollars (the point on your record and opportunity for traffic school doesn’t matter to you). You are betting the judge doesn’t want to waste time with a trial. (except now he knows there won’t be a trial, oops). You can still try arguing it; good chance it will work.

However, if the failure to appear exists, it’s more complicated. You must get that dismissed! You can argue your bona-fide effort to reach the courthouse previously. It would have helped if you were standing in front of him personally, obviously come quite a distance and effort to answer this charge, can’t do that now, but judges are pretty sanguine about dismissing failure-to-appear if you really do appear (via lawyer is fine) willingly out of your own initiative Of course, this will only impress them if you do it right away.

The key is to resolve it together with the underlying ticket as a plea-bargain; if you already resolved the ticket, you have nothing to bargain with! So you ask the judge to dismiss the failure-to-appear if you plead guilty on the 99 mph. Or if that is not acceptable to the judge, ask to dismiss the FTA if you plead guilty on 111mph.

How do you argue this now you’re gone?

I would have said to try trial-by-mail. However the CVC 22348(b) is crystal clear; you must show up in court in person: either you or your lawyer.

If the failure-to-appear was not a factor, I might have said try it anyway and see if it works. But it’s a gamble; the judge may not have the freedom to waive the CVC 22348(b) requirement since you always can hire a lawyer.

However, dismissing the failure-to-appear is an absolute top priority. This would make you an international criminal, and that’s not nearly as much fun as the James Bond movies make it out to be.

As such, I would say you are pretty much stuck with hiring a lawyer. Because he can manage every possible contingency. He’s pretty much going to argue what I said above. You could’ve done it yourself if you’d done it sooner. Live and learn.

It really doesn’t help your case that you were inside the USA the entire time the ticket was pending and you did nothing. They will feel like you consider their court a joke. On the other hand, if you retain a lawyer after you had already made your escape, that says you take your relationship with America seriously, and earlier was a novice mistake you own up to. They will not care that you fled the country since they would not have sent you to jail for this.

You need to do this right away. If you wait months — or worse, if you put it off until the next time you want to visit the USA! — it will be much, much worse. It happens all the time where a traveler clears the pre-check, arrives at JFK Airport, and gets denied entry because of something the pre-check missed and put on a plane back home (at his expense).



By the way, when you sign a traffic ticket in CA and many other states, you are not admitting guilt. You are swearing a promise to appear in court, which is part of a fair exchange: you promise to appear later, and they let you go now. If you are convicted of violating that promise, you won’t be trusted in the future, and could be hauled to jail while you watch your friends be cited and released for the exact same charge.

And if an FTA remains unresolved, then the next time any state officer stops you for any reason, he will probably take you to jail. (he’ll make a judgment call based on his ability and the seriousness of the underlying crime). Sorry, if you’re sitting at JFK Airport, California will not pay to get you extradited (give you a free flight to CA) for a speeding ticket.

Also, if you had a CA driver’s license, insted of 99 you’d plead 29 over the speed limit; 30-over disqualifies you for traffic school by mail, which would remove the point from your record.

python – Booking an East London Tennis Court

I’m not sure if it Covid-19 but lately it is impossible to book a tennis court in my area on time. It’s always full or maybe just don’t check enough 🙂

To beat the queue and get notified earlier, I started making a scraper to ensure I can book a court on time.

But because of iframe hell and the lack (to my knowledge) of an API it was impossible to do it the easy way, hence I used selenium. I coded this today and it works pretty well, although it’s already become a bit of a mess.

Dynamically detecting the hours available and starting time of the day, so I don’t have to supply those values anymore, because my guess is they will change (depending on the time it will get dark etc.)

You can still flame me for it, but I just haven’t found a good way to do it yet, now I just supply them in the COURTS dictionary

#!/usr/bin/python3

import time

from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By

# At what minimal time I am willing/able to book
WEEKEND_TIME = 10
WEEK_TIME = 18

COURTS = {
    # Some courts have different hours available and the hour at which you can start can differ
    # Thus it is key -> name with values -> url, hours available, time diff start
    "Bethnal Green Gardens" : ("https://www.towerhamletstennis.org.uk/bethnal-green-gardens-court-bo", 14, 0),
    "St Johns Park"         : ("https://www.towerhamletstennis.org.uk/st-johns-park-court-boo", 14, 1),
    "Poplar Rec"            : ("https://www.towerhamletstennis.org.uk/poplar-rec-court-bookin", 12, 0),
    "King Edward's Park"    : ("https://www.towerhamletstennis.org.uk/kemp-court-bookin", 12, 0),
    "Victoria Park"         : ("https://www.towerhamletstennis.org.uk/victoria-park-court-book", 12, 0),
}

def get_week_schedule(driver, time_length, time_start, first_week=True):
    elem = driver.find_element_by_xpath('//div(@class="cal_time cal_time_time")')
    sched = (e.text for e in elem.find_elements_by_xpath('//div(@class="inc")'))
    times = sched(time_start:17)
    active = sched(17:)

    # When first week we only want from x till sunday and second week monday till x
    days = ("Sunday", "Saturday", "Friday", "Thursday", "Wednesday", "Tuesday", "Monday")
    active_days = days(:len(active) // time_length)(::-1) if first_week 
             else days(::-1)(:len(active) // time_length)
    
    week_schedule = {}
    for i, active_day in enumerate(active_days):
        week_schedule(active_day) = {
            int(times(j).split(":")(0)) : active(i * time_length + j)
            for j in range(time_length)
        }
    return week_schedule

def get_court_schedule(driver, data):
    url, time_length, time_start = data
    driver.get(url)
    
    # Yo dawg, I heard you like iframes so I put an iframe in your iframe...
    WebDriverWait(driver, 3).until(EC.presence_of_element_located((By.XPATH, "//iframe")))    
    driver.switch_to.frame(driver.find_element_by_tag_name("iframe"))
    driver.switch_to.frame(driver.find_element_by_tag_name("iframe"))

    court_schedule = {}
    court_schedule("this") = get_week_schedule(driver, time_length, time_start)

    # Next week is second element
    elem = driver.find_elements_by_xpath("//a(@href)/span")
    elem(1).click()
    # TODO Fix time.sleep...  but same page so how can we wait?
    time.sleep(5)
    court_schedule("next") = get_week_schedule(driver, time_length, time_start, first_week=False)

    return court_schedule

def get_schedule():
    driver = webdriver.Chrome()

    court_schedules = {
        court_name : get_court_schedule(driver, url)
        for court_name, url in COURTS.items()
    }

    driver.quit()
    return court_schedules

def get_available_dates(schedule):
    for court_name, court_schedule in schedule.items():
        for week, week_schedule in court_schedule.items():
            for day, day_schedule in week_schedule.items():
                earliest_time = WEEKEND_TIME if day in ("Saturday", "Sunday") else WEEK_TIME
                for hour, available in day_schedule.items():
                    if hour >= earliest_time and available not in ("Full", " "):
                        print(f"Can book at court {court_name} {week} week on {day} at {hour} for price {available}")

if __name__ == "__main__":
    schedule = get_schedule()
    get_available_dates(schedule)
./tennis.py
Can book at court Poplar Rec next week on Saturday at 10 for price £6
Can book at court Poplar Rec next week on Saturday at 11 for price £6
Can book at court King Edward's Park this week on Saturday at 18 for price £6
Can book at court King Edward's Park next week on Friday at 18 for price £6
Can book at court King Edward's Park next week on Saturday at 10 for price £6
Can book at court King Edward's Park next week on Saturday at 11 for price £6

❕NEWS – UK court shuts down scam cryptocurrency £1.5 million | Proxies-free

The UK High Court has ordered the closure and wind-up of GPay, a cryptocurrency platform that scammed traders through fake celebrity endorsements.

On June 30, the UK government’s Insolvency Service posted a notice which explained that GPay Ltd, trading as XtraderFX — formerly known as Cryptopoint — has been closed after “losing” £1.5 million ($1.8m) of investor funds.

At least 108 clients lost cash, even when they opted for insurance that was meant to cover any future financial losses. When traders attempted to withdraw any funds they plowed into the platform, they hit barrier after barrier, such as ID and utility document requirements — but, of course, these checks were not required to make deposits.

XtraderFX’s website has now been shut down, but cached versions of the domain reveal promises of an easy cryptocurrency trading platform and portfolio, as well as a mining platform.

The platform promised to provide a way for those without any former experience in cryptocurrency trades to invest, on the backing of experienced traders and computational tools to make the task easy.

However, cryptocurrency scams, fake Initial Coin Offerings (ICOs), and exit scams are rife in the community. While regulators worldwide have begun to try and clamp down on fraud, unless a cryptocurrency exchange is registered under a government agency such as the US Securities and Exchange Commission (SEC), investors are often trading at their own risk

GPay targeted individuals in the UK and elsewhere through advertising campaigns online, including through a variety of social media channels.

“Customers were encouraged to use GPay’s online trading platform through advertisements that falsely claimed the service was supported or endorsed by entrepreneurs that starred in a prime-time TV show and a high-profile money-saving website,” UK regulators say.

Trustpilot users have complained of deposits made without permission, closed accounts without warning, and harassment via phone calls urging additional investment.

The use of well-known, trusted faces to fraudulently advertise cryptocurrency schemes runs rampant. In this case, a number of users said they fell for a fraudulent Dragon’s Den advertisement on Facebook.

Martin Lewis, the founder of MoneySavingExpert, has also been fighting the fraudulent use of his image to promote such schemes for years.

The financial expert previously took Facebook to court for the abuse of his name and image in thousands of scam adverts on the social network. Lewis and Facebook settled the case after Facebook promised to launch a dedicated scam ads report tool and to donate £3 million to a Citizens Advice project to help tackle scam-related complaints.

TechRepublic: How to protect your remote desktop environment from brute force attacks

In response to the news of GPay’s closure, Lewis said:

“Screw you! P*ss off! And good riddance Gpay Ltd.”

GPay was formally wound up on June 23, and UK officials say the order was made “in the public interest.” No appeal was made by the company against the decision.

The Official Receiver is now the liquidator of the company.

“We welcome the court’s decision to wind-up GPay as it will protect anyone else becoming a victim,” commented David Hill, a Chief Investigator for the Insolvency Service. “This scam should also serve as a warning to anyone who conducts trading online that they should carry out appropriate checks before they invest any money that the company is registered and regulated by the appropriate authorities.”

❓ASK – Can we see an online court in the future ? | Proxies-free

Ever thought of an online court that solves online issues whenever it comes to online scams ? that would bring a lot to online money making world as scammers will really decrease as there will be finally someone who will help punishing them and move the case from an online scam to an offline punishement, can we see something like this in the future ?

python 3.x – Crawling a court website and downloading records

I am relatively new to python. Amateur learner.

working on Python 3.8 and Selenium

I have re-written following code. I posted previous code HERE and received several useful suggestions. On basis of that following updated code was written.

Now, the code works fine. Much better than previous. But, I wonder 1. How can convert it to Page Object based code (by shifting some part in to classes)? 2. Is that (refactoring) going to help improve the speed or readability etc?

I tried with classes. but then except for creating directories and for selecting particular district or complex. And rest of the functions inside those classes remain static.

I don’t expect any one to re-write whole code for me… but then elaboration on approach or just a pointer to refactoring etc.
Note: kindly ignore comments (‘#’) they are not yet well formed.

import base64
from typing import List
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support.ui import Select
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.webdriver.firefox.options import Options as FirefoxOptions
import time
import os
from PIL import Image
from io import BytesIO
import cv2
from pytesseract import pytesseract
from selenium.common.exceptions import NoSuchElementException, TimeoutException, ElementNotInteractableException
import logging

# set logging
logging.basicConfig(filename='/home/sangharshmanuski/EcourtsData/logging_files'
                             '/ecourts_log_file.log',
                    filemode='a',
                    level=logging.INFO,
                    format='%(asctime)s %(message)s',
                    datefmt='%d/%m/%Y %I:%M:%S %p')
# constants
url = r'https://districts.ecourts.gov.in/'

options = FirefoxOptions()
options.add_argument("--headless")
options.add_argument("--private-window")
driver = webdriver.Firefox(options=options)
# base dir path for downloading files:
main_Directory = r'/path to the directory/downloads6'
combo_identifier = '#sateist'
wait = WebDriverWait(driver, 180)
waitShort = WebDriverWait(driver, 3)


# FUNCTIONS

def get_states(driver) -> List(str):
    """Get list of States/UT from combo box
    Return a list of strings
    """
    try:
        # wait for combo box to be ready

        wait.until(EC.presence_of_element_located((By.CSS_SELECTOR, combo_identifier)))

    except TimeoutException:
        logging.exception('list of states failed to load')

    states_combo = Select(driver.find_element_by_css_selector(combo_identifier))

    # return list of non-empty values from combo box
    state_list = (o.get_attribute("value") for o in states_combo.options if o.get_attribute("value") != '')
    logging.info('state list ready')
    return state_list


def get_districts():
    """
    Get list of districts form options
    It returns two values.
    1 is name (text from the element) of the district
    2 is value (attribute value) of that district
    """
    try:
        # wait for page to open and banner of district court to appear.
        wait.until(EC.presence_of_element_located((By.CSS_SELECTOR, '.region')))
    except TimeoutException:
        logging.exception('districts not loaded')

    states_combo = Select(driver.find_element_by_css_selector(combo_identifier))
    # return list of non-empty values from combo box
    districts_names = (o.get_attribute(
        "text") for o in states_combo.options if o.get_attribute("value") != '')
    district_values = (o.get_attribute(
        "value") for o in states_combo.options if o.get_attribute("value") != '')
    for each_district, number in enumerate(districts_names, start=1):
        logging.info(f'all the districts are:')
        logging.info(f'({number}): {each_district}')
    logging.info(f'district list ready. total districts: {len(districts_names)}.')

    return districts_names, district_values


def single_district(dist_number, some_districts_names=None, some_districts_values=None):
    # returns single district name and value of the district
    name_dist = some_districts_names(dist_number)
    value_dist = some_districts_values(dist_number)
    district_option = Select(driver.find_element_by_css_selector(combo_identifier))
    district_option.select_by_value(value_dist)
    logging.info(f'n n n new district: {name_dist} selected. It's number: {dist_number}')
    return name_dist, value_dist


def match_heading(some_district_name=None):
    heading_dist = driver.find_element_by_css_selector('.heading')
    heading_dist_lower = heading_dist.text.lower()
    some_district_name_lower = some_district_name.lower()
    while heading_dist_lower != some_district_name_lower:
        time.sleep(1)
        logging.info('waiting')
    else:
        logging.info(f'district: {some_district_name} '
                     f'page loaded fully. Selecting case status by act')
        return True


def case_status_by_act():
    wait.until(
        EC.element_to_be_clickable((By.CSS_SELECTOR, 'button.accordion2:nth-child(2)'))).click()
    select_case_status_by_act = wait.until(EC.element_to_be_clickable(
        (By.CSS_SELECTOR,
         'div.panel:nth-child(3) > ul:nth-child(1) > li:nth-child(6) > a:nth-child(1)')))
    select_case_status_by_act.click()
    logging.info('Case status by act selected. new tab will open')
    return select_case_status_by_act


def court_complex_list():
    wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, '#court_complex_code')))
    complex_combo = Select(driver.find_element_by_css_selector('#court_complex_code'))
    # return list of non-empty values from combo box
    court_complex_names = (o.get_attribute("text")
                           for o in complex_combo.options if o.get_attribute("value") != '0')
    court_complex_values = (o.get_attribute("value")
                            for o in complex_combo.options if o.get_attribute("value") != '0')
    logging.info(f'number of court complexes available: {len(court_complex_names)}')
    return court_complex_names, court_complex_values


def single_court_complex(complex_number, value_complex_list=None, name_complex_list=None):
    # returns single court complex name and value of the same
    complex_combo = Select(driver.find_element_by_css_selector('#court_complex_code'))
    value_complex = value_complex_list(complex_number)
    name_complex = name_complex_list(complex_number)
    complex_combo.select_by_value(value_complex)
    logging.info(f'n {name_complex} selected. checking for records')
    return name_complex


def select_act(some_name_complex=None):
    """Populates list of acts.
    if the list is empty it waits for a 1 sec and tries again
    after trying 10 times it closes the effort and returns"""
    acts = Select(driver.find_element_by_css_selector('#actcode'))
    act_list = acts.options
    second = 0
    while len(act_list) < 2:
        if second < 10:
            time.sleep(1)
            second += 1
            logging.info('waiting for act list to be ready...')
        else:
            logging.info(f"sorry no act in {some_name_complex}")
            return False
    else:
        logging.info(f'PoA selected')
        acts.select_by_value('33')
        return True


def accept_alert(tab=None):
    try:
        waitShort.until(EC.alert_is_present())
        driver.switch_to.alert.accept()
        driver.switch_to.window(tab)
        logging.info('alert accepted')
        return True
    except (NoSuchElementException, TimeoutException):
        logging.exception('no alert present')
        return False


def wait_msg():
    try:
        please_wait = driver.find_element_by_css_selector('#waitmsg')
        if please_wait.is_displayed():
            logging.info('please wait')
            return True
        else:

            return False
    except NoSuchElementException:
        logging.exception('no wait msg was present')
        return False


def wait_msg_wait():
    # wait for wait msg to disappear only for 5 sec
    # in case of alert wait msg remains for ever so waiting only for 5 sec is imp
    sleep = 1
    while wait_msg():
        if sleep < 6:
            time.sleep(sleep)
            sleep += 1
            continue
        else:
            break
    logging.info('captcha result ready')
    return


def invalid_captcha():
    # if captcha is invalid it returns true.
    try:
        incorrect = driver.find_element_by_css_selector('#errSpan > p:nth-child(1)').text
        in_valid_captcha = "Invalid Captcha"
        if incorrect == in_valid_captcha:
            logging.info(f'{incorrect}, try again')
            return True
        else:
            logging.info('captcha cracked correctly')
            return False
    except NoSuchElementException:
        logging.info('captcha cracked, but may be no records found...checking')
        return False


def no_record_found(courtcomplex=None):
    # checks if no record found message is displayed

    try:
        no_record = driver.find_element_by_css_selector('#errSpan > p:nth-child(1)').text
        no_record_available = "Record Not Found"
        if no_record == no_record_available:
            logging.info(f'no record @ {courtcomplex} please go to next court complex')
            return True

    except NoSuchElementException:
        logging.info('captcha cracked, record available, download now')
        return False


def captcha_to_text():
    # captures the captcha image
    logging.info('working on captcha now...')
    elem = driver.find_element_by_id("captcha_image")
    loc = elem.location
    size = elem.size
    left = loc('x')
    top = loc('y')
    width = size('width')
    height = size('height')
    box = (int(left), int(top), int(left + width), int(top + height))
    screenshot = driver.get_screenshot_as_base64()
    img = Image.open(BytesIO(base64.b64decode(screenshot)))
    area = img.crop(box)
    full_path = r'/home/sangharshmanuski/Documents/e_courts/captcha'
    area.save(os.path.join(full_path, 'file_trial.png'), 'PNG')
    img = cv2.imread(os.path.join(full_path, 'file_trial.png'), 0)
    ret, thresh1 = cv2.threshold(img, 111, 255, cv2.THRESH_BINARY)
    cv2.imwrite(
        '/home/sangharshmanuski/Documents/e_courts/editC/oneDisNoLoop.png', thresh1)
    # know the text with pytesseract
    captcha_text = pytesseract.image_to_string(
        Image.open(
            '/home/sangharshmanuski/Documents/e_courts/editC/oneDisNoLoop.png'))
    logging.info(f'text of the captcha: {captcha_text}')
    return captcha_text


def submit_form():
    # "enters captcha text taken from crack_captcha(..) function"
    captcha = driver.find_element_by_id('captcha')
    captcha.send_keys(captcha_to_text())
    driver.find_element_by_css_selector('input.button:nth-child(1)').click()
    time.sleep(1)
    logging.info('form submitted')


def download(some_district=None, some_complex=None):
    logging.info(f'okay, downloading record for {some_complex} in {some_district}')
    WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.CSS_SELECTOR, 'a.someclass')))
    list_all_view = driver.find_elements_by_css_selector(
        'a.someclass')
    logging.info(f'total number of records: {len(list_all_view)}')
    record = 0
    for view in list_all_view:
        logging.info(f'downloading {list_all_view.index(view)} record')
        view.click()
        wait.until(EC.presence_of_element_located((By.ID, 'back_top')))
        open_file = open(
            os.path.join(main_Directory, some_district,
                         some_complex, "file_" + str(record) + ".html"), "w")
        open_file.write(driver.page_source)
        open_file.close()
        back = driver.find_element_by_id('back_top')
        back.click()
        record += 1

    logging.info(f'{some_complex} in {some_district} downloaded')


def dist_dir(some_district_name=None):
    district_directory = os.path.join(
        main_Directory, some_district_name)  # create new
    if not os.path.exists(district_directory):  # if not directory exists, create one
        os.mkdir(district_directory)
        logging.info(f'directory for {some_district_name} created')
    else:
        logging.info(f'directory for {some_district_name} was already there')
        pass
    return district_directory


def court_complex_dir(district_directory=None, name_complex=None):
    # makes separate directory particular court complex
    court_complex_directory = os.path.join(
        main_Directory, district_directory, name_complex)  # create new
    if not os.path.exists(court_complex_directory):  # if not directory exists, create one
        os.mkdir(court_complex_directory)
        logging.info(f'directory for {name_complex} in '
                     f'{district_directory} created')
    else:
        logging.info(f'directory for {name_complex} in '
                     f'{district_directory} was already there')
        pass
    return court_complex_directory


# MAIN CODE

# load the main page
driver.get(url)
print('working in progress. see the log file')
# Step 1 - select a state from list of states
# fixed selection from list. As only Maharashtra is covered now.

state_option = Select(driver.find_element_by_css_selector(combo_identifier))
state = state_option.select_by_value('maharashtra')
list_districts_names, list_districts_values = get_districts()
# Step 2 - district object created
for x in list_districts_names:
    logging.info(f'district loop started. iteration: '
                 f'{list_districts_names.index(x)}')
    # step 2.1- select single district
    this_district, this_value = single_district(list_districts_names.index(x),
                                                list_districts_names,
                                                list_districts_values)

    dist_dir(this_district)

    match_heading(this_district)
    # step 2.3.a create variable for window handle
    current = driver.window_handles(0)
    # step 2.4 - a. select case status by act and b. switch to new window
    case_status_by_act()
    wait.until(EC.number_of_windows_to_be(2))
    # define new tab by differentiating from current tab.
    newWindow = (window for window in driver.window_handles if window != current)(0)
    # 2.4.a
    # switch to the new tab. ref:
    # https://stackoverflow.com/questions/41571217
    # /python-3-5-selenium-how-to-handle-a-new-window-and-wait-until-it-is-fully-lo
    driver.switch_to.window(newWindow)
    # 2.4.b new object from Formfilling(districtCourt)
    this_name_complex_list, this_value_complex_list = court_complex_list()

    # 2.4.c loop over all complexes

    for i in this_name_complex_list:
        logging.info(f'n iterating each complex. currently at no.: {this_name_complex_list.index(i)}')
        # 2.4.1.1 select court complex
        this_name_complex = single_court_complex(this_name_complex_list.index(i),
                                                 this_value_complex_list,
                                                 this_name_complex_list)
        # 2.4.1.2 select act. 
        # If the acts are not available go to the next court complex
        # or if option for particular act is not present go to next court complex
        if not select_act(this_name_complex):

            driver.find_element_by_css_selector('input.button:nth-child(2)').click()
            single_court_complex(this_name_complex_list.index(i),
                                 this_value_complex_list,
                                 this_name_complex_list)
            if not select_act(this_name_complex):
                continue
        while True:
            submit_form()

            if accept_alert(newWindow):
                driver.find_element_by_css_selector('#captcha_container_2 '
                                                    '> div:nth-child(1) > div:nth-child(1) '
                                                    '> span:nth-child(3) > a:nth-child(7) '
                                                    '> img:nth-child(1)').click()
                time.sleep(1)
                logging.info('captcha image refreshed')
                continue

            if not invalid_captcha():

                break
            else:

                continue
        # 2.4.5 if no record found go the next court complex
        if no_record_found(this_name_complex):
            continue  # skip rest of the code and continue the for loop from start.
        else:
            # 2.4.6 make new directory
            court_complex_dir(this_district, this_name_complex)
            # 2.4.7 download all the records
            try:
                download(this_district, this_name_complex)
            except (TimeoutException, NoSuchElementException, ElementNotInteractableException):

                driver.refresh()
                logging.exception(f'exception was present. Recheck {this_name_complex} again.')
                logging.info(f'skipping {this_name_complex} for now')
                continue

    logging.info(f'all court complexes in {this_district} completed')
    print(f'all court complexes in {this_district} completed')
    driver.close()
    driver.switch_to.window(current)

logging.info('all districts in maharashtra completed')
# 2.4.8 close the form page
driver.close()

# 2.5 all districts completed print statement and go to state-option page.

driver.back()

Thank you.