Python Forum
Minimizing the CMD window during code execution
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Minimizing the CMD window during code execution
#1
Hi,
Attaching the snippet of my code.

Objective: I am trying to ping a website for certain interval of time (User defined). If the URL works, it will open the webpage in the default browser. If not it will keep pinging until the user defined time interval expires.

Issue: Code works perfectly but at instruction
Quote:response = os.system("ping " + url)
, it pops up the cmd window on screen and I need to minimize it every time. It is irritating to do it manually all the time. Is there any way I can resize the terminal window or make it minimize all the time until the code expires?

A little manual study lands me to this os.get_terminal_size() but nothing much.


import os, time, webbrowser

#Enter URL that need to check. Add input()
url = "167.6.2.200"
input_time = float(input("How long ping should work: "))

current_time = time.time()   #note current time
actual_time = 0
isHostOn=0

#r = (os.get_terminal_size())
response =0 

#Execute the loop till the time expires entered by User
while((input_time + current_time) > actual_time): 
    response = os.system("ping " + url)
    if response ==0:
        webbrowser.open_new_tab("https://167.6.2.200:446/")
        break;
    else:
		#add Exception if any
        #print("no")
        pass # do nothing

    actual_time = time.time()
    #time.sleep(5)
Reply
#2
I have got to know about the subprocess and its return value.

Probably this StackoverFlow link will help:
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Different code execution times Wirbelwind94 4 766 Oct-06-2023, 12:30 PM
Last Post: snippsat
  Is there a way to call and focus any popup window outside of the main window app? Valjean 6 1,799 Oct-02-2023, 04:11 PM
Last Post: deanhystad
  In consistency in code execution Led_Zeppelin 1 1,120 Jun-27-2022, 03:00 AM
Last Post: deanhystad
  Pyspark Window: perform sum over a window with specific conditions Shena76 0 1,185 Jun-13-2022, 08:59 AM
Last Post: Shena76
  run code in a window vs console gehrenfeld 1 2,163 Dec-20-2018, 02:38 PM
Last Post: gehrenfeld
  code execution after event shift838 3 2,833 Nov-26-2018, 05:10 AM
Last Post: Larz60+
  How to Make Python code execution pause and resume to create .csv and read values. Kashi 2 3,777 Jun-14-2018, 04:16 PM
Last Post: DeaD_EyE
  Another working code, help required for faster multithreading execution anna 0 2,263 Feb-09-2018, 03:26 AM
Last Post: anna
  Help required for faster execution of working code anna 2 3,160 Feb-09-2018, 03:00 AM
Last Post: anna
  code to understand the script execution Skaperen 2 3,360 Jan-06-2018, 05:25 AM
Last Post: Skaperen

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020