-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBeispiel_OO_5_Properties.py
More file actions
67 lines (56 loc) · 1.35 KB
/
Beispiel_OO_5_Properties.py
File metadata and controls
67 lines (56 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/local/bin/python3
##############################################
#
# Name: Beispiel_OO_5_Properties.py
#
# Author: Peter Christen
#
# Version: 1.0
#
# Date: 10.06.2017
#
# Purpose: OO Beispiel mit Properties
#
##############################################
import platform,os,time
####Variablen
server=''
####Classes
class Server:
#Konstruktor Methode
def __init__(self,name):
#Attribute
self.name=name
self.nrcpu=0
self.system=''
self.release=''
self.machine=''
#Weitere Methode
def showdata(self):
print ("\nServer Angaben\n##############")
print ("Name:", self.name)
print ("Nr.CPU:", self.nrcpu)
print ("System:", self.system)
print ("Release:", self.release)
print ("Machine:", self.machine)
print ("Timestamp:", int(self.timestamp))
def getTimestamp(self):
__timestamp=time.time()
return __timestamp
#Destruktor Methode
def __del__(self):
print ("\nLösche", self.name, "wieder")
timestamp=property(getTimestamp)
####Objekt erfassen
server=Server(platform.node())
####Basis Daten erfassen
server.nrcpu=os.cpu_count()
server.system=platform.system()
server.release=platform.release()
server.machine=platform.machine()
####Daten ausgeben
server.showdata()
print (server.timestamp)
server.timestamp=1000000
print (server.timestamp)
server.showdata()