Wednesday, March 11, 2020

Its the little things (like opening a web browser)

Sometimes as your developing a solution/script for a problem your faced with interesting challenges where the dumbest workaround (opening a web browser and authenticating with a service) fixes your issue.

Making this simple for a user; who is transitioning mediums (from a cli to a web browser) - this can be interesting technical challenge.

My solution (in python, because that's what I am writing my script in):

    args = parser.parse_args()
    try:
        ### Authenticate with some service, Example below
        ### service = SERVICE(args.server, auth=(username, password)) 
    except SERVICE_Error as e:
        if "ERROR_KEY" in e.text:  # Your key identifier where you know you have 'this one particular issue' 
            print("ERROR: log in to {} using 'incognito' mode in your browser to reset the CAPCHA failed login counter".format(args.server))
            import webbrowser; wb = webbrowser.get()
            if 'chrome' in wb.name:
                wb.remote_args.insert(1, "--incognito")
            elif 'firefox' in wb.name:
                wb.remote_args.insert(1, "--private-window")
            print("INFO: Opening default web-browser in --incognito/--private-window for you! Login to reset the failed log-in counter.")
            print("INFO: After logging in on the web-browser rerun the cli script and authenticate correctly")
            wb.open_new(args.server)

11 comments:

  1. I wanted to leave a little comment to support you and wish you a good continuation. Wishing you the best of luck for all your blogging efforts. Wikipedia

    ReplyDelete
  2. Looking to travel to Islamabad? A large number of cheap flights are available for your travel to Pakistan. You can take cheap flights to Islamabad for your trip and tours. Everyone wants to save hard earned money, so taking a cheap flight deal is one of the good options. Islamabad is the tenth largest city and capital of Pakistan. This city is well known for it's hostility and friendly people. Cheap Flight

    ReplyDelete
  3. When looking to get a website designer designed or developed, how do you know which web designer to use? There are so many to choose from. Web designers will vary in skill and style and the following article will highlight some points on how to choose the right one.

    ReplyDelete
  4. I felt exceptionally glad while perusing this site. This was truly exceptionally enlightening site for me. I truly preferred it. This was truly a sincere post. Much obliged!.  brochure printing discounts

    ReplyDelete
  5. wow, great, I was wondering how to cure acne naturally. and found your site by google, learned a lot, now i’m a bit clear. I’ve bookmark your site and also add rss. keep us updated. 羅氏鮮官網

    ReplyDelete
  6. There are many airlines and travel agencies offering cheap flights to New York. Well known for its mix of culture and prosperity, New York has a steady number of visitors during the peak seasons and off-peak seasons mainly due to its trading businesses at Wall Street. cheap flights to orlando

    ReplyDelete
  7. This comment has been removed by the author.

    ReplyDelete
  8. This comment has been removed by the author.

    ReplyDelete
  9. Those felines are wonderful! I love meeting creatures while voyaging as well. The deer in in dubai are so astonishing, caused me to feel like I was in a Disney film!
    cheap airline tickets uk

    ReplyDelete

Its the little things (like opening a web browser)

Sometimes as your developing a solution/script for a problem your faced with interesting challenges where the dumbest workaround (opening a ...