Python: feedback / corrections on first OOP style script -


I want some feedback on my first python script that uses the OOP style, it's a muni plugin that plugins (dell_fans, Dell_temps uses the average fan speed or average chassis floating graph based on the name.

An hour or so before that in the fan speed plugin, to get the help of stack overflow to convert it into an open style then I created the two scripts to combine any feedback, suggestions , Improvements will be very helpful

Updates : I would like to correct any misconceptions to be modified for the general base class. Any other suggestions?

  Import System Import Subprocess Class Data (object): def __init __ (self, command): self.command = command.split () DEF average (self): data = subprocess.Popon ( Self.command, stdout = subprocess.PIPE) .stdout.readlines () Count = Total = 0 for item in data: If "read" in the item: #Executive length fan speed, without regex Total + = Float (item split (":") [1] .split () [0]) Count + = 1 # OMOVERPORT sometimes returns omreport zero output if OMS service is not started. If not counting or not total: Price increase ("There is no output from omreport." What does OMSA services have started?) Average = (total / calculated) Return Average Df print_autoconfig (self): Printed "AutoConfig goes here "Square fancy: stat __init __ (self, command): statistics .__ init __ (self, command) def print_config (self): print" graph_title average fan speed "print" graph_args --base 1000 -l 0 " Print "graphs / speed motion (rpm)" print "graph_category chassis" print " Af_Inffa This article shows the average speed of all fans "print" graphs_from other "print" data.The speed of the label "print" data.info average fan speed for five minutes. "Class temps (statistics): def __init __ (self , Command): statistics .__ init __ (self, command) def print_config (self): print "graph_title average temperature" print "graph_args -upper-limit 120 -l 0" print "graph_vlabel celsius" print "graph_class chassis" print " Graph_info This article contains all sensors Reflects the average temperature of the "print" graph_precious second "print" data. Label temp "print" data.info average chassis temperature for five minutes. " If __name__ == '__main__': #munein sowsargs [1] with "" (an empty argument), it removes it. Sys.argv = [xs.x for X in sys.argv] "fans" in sys.argv [0]: CMD = "/ USR / SBI / Omerport chassis fans" omdata = fanpid (CMD) alip "temps" In Sys.argv [0]: cmd = "/ usr / sbin / omreport chassis temps" omdata = Temps (cmd) Other: Print & gt; & Gt; Sys.stderr, "File name changed to dell_fans or dell_temps." Sys.exit (1) if LAN (sys.argv) & gt; 1: If sys.argv [1] .lower () == "autoconfig": omdata.print_autoconfig () elif sys.argv [1]. Flowers () == "config": omdata.print_config () and: try: average = omdata.average () print "data.value% s" OSError, e: print & gt; & Gt; Sys.stderr, "Error in running error"% s,% s "% (cmd, e) sys.exit (1) except ValueError, E: # Occasionally omreport returns zero output if omma service is not started Print & gt; & Gt; Sys.stderr, 'Error: "Omwellport Chassis fans" returned 0 outputs. Print & gt; & Gt; Sys.stderr, 'Ohmasa going on? Try: "srvadmin-services.sh status". ' Temps   

temps A FanSpeed ​​? It is a litmus test whether sub-clinging is appropriate (for example an elephant is an animal, a car is not an animal - so it may be appropriate to have a subclass of animal Elephant, but not the sub-class of Animal which model the car.)

It seems that they are modeling two different things - Yes, create a common base class for them.


Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -