Skip to content
This repository has been archived by the owner on Oct 22, 2020. It is now read-only.

Commit

Permalink
Code cleanup: convert tabs to spaces
Browse files Browse the repository at this point in the history
On couple of places there are tabs instead of spaces.
  • Loading branch information
kepi committed Dec 9, 2015
1 parent 1c16d7e commit 08c1525
Showing 1 changed file with 29 additions and 25 deletions.
54 changes: 29 additions & 25 deletions apache-top.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,9 +261,9 @@ def print_screen(screen, url, show_scoreboard, apache_version):
show_scoreboard = 1
message = "Showing mod_status scoreboard"
else:
show_scoreboard = 0
message = "Hiding mod_status scoreboard"
y = 0
show_scoreboard = 0
message = "Hiding mod_status scoreboard"
y = 0
elif c == "a":
# mostra els actius
if show_only_active:
Expand All @@ -282,8 +282,8 @@ def print_screen(screen, url, show_scoreboard, apache_version):
message = "Normal sorting"
c = ""

except IndexError:
raise
except IndexError:
raise
except:
pass

Expand Down Expand Up @@ -341,22 +341,22 @@ def main(url, stdscr, show_scoreboard, apache_version):
Usage: apache-top [-s] -u url
-u url Url where apache-status is located
Example: apache-top.py -u http://www.domain.com/server-status
Example: apache-top.py -u http://www.domain.com/server-status
-s Show scoreboard
Interactive keys:
q Exit
P Sort by PID
C Sort by CPU usage
S Sort by Seconds since beginning of most recent request
V Sort by VirtualHost
M Sort by Mopde of operation
R Sort by Request
I Sort by Ip
s Show/Hide mod_status scoreboard
a Switch between show all processes and show only active processes (default)
r Reverse sort
q Exit
P Sort by PID
C Sort by CPU usage
S Sort by Seconds since beginning of most recent request
V Sort by VirtualHost
M Sort by Mopde of operation
R Sort by Request
I Sort by Ip
s Show/Hide mod_status scoreboard
a Switch between show all processes and show only active processes (default)
r Reverse sort
"""

Expand All @@ -377,9 +377,9 @@ def main(url, stdscr, show_scoreboard, apache_version):
}

try:
print_screen(stdscr,url,show_scoreboard,apache_version)
print_screen(stdscr,url,show_scoreboard,apache_version)
except:
raise
raise


if __name__ == "__main__":
Expand All @@ -405,11 +405,15 @@ def main(url, stdscr, show_scoreboard, apache_version):
print "*** ERROR: Url missing\n"
usage()

# detect apache version
try:
data = ApacheStatusParser()
statusdata = urllib.urlopen(url).read()
# detect apache version
apache_version = re.search('Server Version: Apache/([^ ]+)', statusdata).group(1)
except:
print "ERROR parsing the data. Please, make sure you are alowed to read the server-status page and you have ExtendedStatus flag activated"
sys.exit(2)

try:
# Initialize curses
stdscr=curses.initscr()
# Turn off echoing of keys, and enter cbreak mode,
Expand All @@ -422,9 +426,9 @@ def main(url, stdscr, show_scoreboard, apache_version):
# a special value like curses.KEY_LEFT will be returned
stdscr.keypad(1)
try:
main(url,stdscr,show_scoreboard,apache_version) # Enter the main loop
except:
raise
main(url,stdscr,show_scoreboard,apache_version) # Enter the main loop
except:
raise
# Set everything back to normal
curses.curs_set(1)
stdscr.keypad(0)
Expand All @@ -439,4 +443,4 @@ def main(url, stdscr, show_scoreboard, apache_version):
curses.nocbreak()
curses.endwin()
#traceback.print_exc() # Print the exception
print "ERROR parsing the data. Please, make sure you are alowed to read the server-status page and you have ExtendedStatus flag activated"
print "ERROR parsing the data. Please, make sure you are alowed to read the server-status page and you have ExtendedStatus flag activated"

0 comments on commit 08c1525

Please sign in to comment.