-
Notifications
You must be signed in to change notification settings - Fork 0
/
T4Wk2.py
96 lines (70 loc) · 1.96 KB
/
T4Wk2.py
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Oct 9 14:38:36 2024
@author: marcus
"""
from time import time, ctime, gmtime
def get_time():
t = time()
return (ctime(t)) #, gmtime(t))
pcTime = get_time()
print(pcTime)
from datetime import datetime #, timezone
def get_Datetime():
return datetime.now()
secondTime = get_Datetime()
print(secondTime)
# print(datetime.utcnow())
# print(timezone)
import os
print("Using OS")
os_name = os.name
os_uname = os.uname()
print(os.name)
print(os.uname())
import sys
print("Using SYS")
print(sys.platform)
osType = sys.platform
print(sys.version) # this tells you Python version
print("Using PLATFORM")
import platform
print(platform.system())
## adding random stuff
##
def get_IPaddress():
if osType == "linux":
print(os.system('ip a'))
else:
print(os.system('ipconfig'))
# this has issues as it's using the OS commands
get_IPaddress()
### open file to write to it
# check to see if file exists...?
# open for writing
with open("testfile.csv", 'w') as f:
f.write(str(pcTime + "," + osType + "," + os_name))
with open('testfile.csv', 'r') as f:
print(f.read())
## stolen from https://www.geeksforgeeks.org/get-your-system-information-using-python-script/
import platform
my_system = platform.uname()
print(f"System: {my_system.system}")
print(f"Node Name: {my_system.node}")
print(f"Release: {my_system.release}")
print(f"Version: {my_system.version}")
print(f"Machine: {my_system.machine}")
print(f"Processor: {my_system.processor}")
# import socket
# local_name = socket.gethostname()
# print(local_name)
# # this tries to connect to Google DNS
# # and tells what IP did the connection
# s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
# s.connect(("8.8.8.8", 80))
# # get the local IP from the socket connection
# local_ip = s.getsockname()
# print(local_ip)
# # only get the first index from the list
# print("the IP that connected is from",s.getsockname()[0])