sonnix-de / computerspende Goto Github PK
View Code? Open in Web Editor NEWA python script to document the hardware in a mantis database and some utilities to clean and install a computer
Home Page: https://computerspende-regensburg.de
A python script to document the hardware in a mantis database and some utilities to clean and install a computer
Home Page: https://computerspende-regensburg.de
Major bug: script fails at detection of cd-rom
checkforcd = subprocess.check_output("sudo --.-.lshw -C disk",shell=True).decode()
The --.-. seems strange
Also it would be way better no just to have "Ja / Nein", but to have a bit more details like if it is able to write DVDs etc.
So if you would call "sudo lshw -json -C disk" and try to extract the node from "id" : "cdrom"
Then you could append all the "capabilities" like that: cd-r cd-rw dvd dvd-ram
This ist the output from my notebook:
{
"id" : "cdrom",
"class" : "disk",
"claimed" : true,
"handle" : "SCSI:02:00:00:00",
"description" : "DVD-RAM writer",
"product" : "DVDRAM GT80N",
"vendor" : "HL-DT-ST",
"physid" : "0.0.0",
"businfo" : "scsi@2:0.0.0",
"logicalname" : ["/dev/cdrom", "/dev/cdrw", "/dev/dvd", "/dev/dvdrw", "/dev/sr0"],
"dev" : "11:0",
"version" : "FS05",
"configuration" : {
"ansiversion" : "5",
"status" : "nodisc"
},
"capabilities" : {
"removable" : "support is removable",
"audio" : "Audio CD playback",
"cd-r" : "CD-R burning",
"cd-rw" : "CD-RW burning",
"dvd" : "DVD playback",
"dvd-r" : "DVD-R burning",
"dvd-ram" : "DVD-RAM burning"
}
}
[ WARN:0] global /tmp/pip-req-build-ms668fyv/opencv/modules/videoio/src/cap_v4l.cpp (893) open VIDEOIO(V4L2:/dev/video0): can't open camera by index
Traceback (most recent call last):
File "main.py", line 8, in
import IssueBuilder as IssueBuilder
File "/home/daniel/Documents/computerspende/IssueBuilder.py", line 59, in
print(build())
File "/home/daniel/Documents/computerspende/IssueBuilder.py", line 50, in build
"name": category(lshwJson)
File "/home/daniel/Documents/computerspende/IssueBuilder.py", line 17, in category
if lshwJson["configuration"]["chassis"] == 'notebook' or lshwJson["configuration"]["chassis"] == 'laptop':
KeyError: 'chassis'
I get this error if I try to run python3 main.py
A small bash script should check, it the installed version is the current version is and install it on the distribution iso.
Das Tool kann evtl. mehrere Aufgaben erledigen, u.a. die Festplatte putzen und das shred kommando starten.
Daher wäre wohl ein einfaches Menü sinnvoll.
(z..b. https://pypi.org/project/simple-term-menu/)
Add availability of CD/DVD drive to the description
Maybe someone has a good solution to write this code here nicer than it is at the moment?
def cdrom():
lshw = json.loads(str(subprocess.check_output("sudo lshw -json -C disk", shell=True).decode()))
for disk in lshw:
if "cdrom" in disk['id']:
capabilities = {disk['capabilities'][k] for k in disk['capabilities'].keys() - {'removable'}} # removes key 'removable' from dictionary
capabilities = sorted(capabilities) # sorts capabilities alphabetically
capabilities = str(capabilities).replace("[","").replace("]", "").replace("'", "") # creates an output that makes sense without square braclets [] and single quotation mark '
if "DVD" in capabilities:
return "DVD-Laufwerk: " + capabilities
elif "CD" in capabilities:
return "CD-Laufwerk: " + capabilities
else:
continue
return "Laufwerk: Kein Laufwerk verbaut"
Add the available interfaces like VGA, HDMI, DVI, DP etc. to the desription
At the moment ctrl+d is used to break up the while loop. This is a little problematic as this key is sometimes not recognized on systems. So there should be a key that is more common like y or something like that.
im aktuellen Mantis sind beim Feld Standort teilweise Leerzeichen vorne und hinten dran
(... | Wolfgang | Ribisl | ....
Diese müssen weg und die custom_field_string ein update gemacht werden um Leerzeichen vorne und hinten weg zu nehmen
ansonsten wird es etwas blöd, den Standort in seinem eigenen Script zu hinterlegen
I think we should set the text, that you can enter during the creation of the issue to the top of the issue
example:
this is the text I entered in the python script
Auflösung: ....
Grafikkarte: .....
USB3: ja
At the moment the hostname will be changed regardless of if I choose to create a mantis entry. Should be changed to if I press N the hostname should not be changed too
Ich denke es wäre sinnvoll den RAM in Mantis ganzzahlig darzustellen. Ergo 4 oder 8 oder 16 GB.
Currently we only set /etc/hostname
In /etc/hosts there is also the previous hostname set.
I don't know what the other one is used for, but we should check I guess.
Th resolution of the screen should be added to the description,
e. g.
Auflösung: 1280x1014
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python3.8/threading.py", line 932, in _bootstrap_inner
self.run()
File "/usr/lib/python3.8/threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "/home/daniel/Documents/computerspende/venv/lib/python3.8/site-packages/consolemenu/console_menu.py", line 169, in _wrap_start
self._main_loop()
File "/home/daniel/Documents/computerspende/venv/lib/python3.8/site-packages/consolemenu/console_menu.py", line 226, in _main_loop
self.process_user_input()
File "/home/daniel/Documents/computerspende/venv/lib/python3.8/site-packages/consolemenu/console_menu.py", line 311, in process_user_input
self.select()
File "/home/daniel/Documents/computerspende/venv/lib/python3.8/site-packages/consolemenu/console_menu.py", line 351, in select
self.selected_item.action()
File "/home/daniel/Documents/computerspende/venv/lib/python3.8/site-packages/consolemenu/items/function_item.py", line 35, in action
self.return_value = self.function(*self.args, **self.kwargs)
File "main.py", line 13, in showHardware
print(hw.getInformationAboutCurrentComputer())
AttributeError: module 'readhw' has no attribute 'getInformationAboutCurrentComputer'
@ the Moment it looks a little ugly as the first line is completely omitted. Would be nicer to use the first line, too!
Ich denke wir sollten hier etwas robuster nach dem Fachbegriff "802.11" suchen, der von lshw -json
mit ausgegeben wird:
wireless" : "IEEE 802.11"
Damit sollten wir eigentlich nur den lshw brauchen und auch nur einen check
Line 69 in 0de0a30
I get this error if I run python main.py:
Traceback (most recent call last):
File "main.py", line 3, in
from consolemenu import *
ModuleNotFoundError: No module named 'consolemenu'
Also it would be way better no just to have "Ja / Nein", but to have a bit more details like if it is able to write DVDs etc.
So if you would call "sudo lshw -json -C disk" and try to extract the node from "id" : "cdrom"
Then you could append all the "capabilities" like that: cd-r cd-rw dvd dvd-ram
This ist the output from my notebook:
{
"id" : "cdrom",
"class" : "disk",
"claimed" : true,
"handle" : "SCSI:02:00:00:00",
"description" : "DVD-RAM writer",
"product" : "DVDRAM GT80N",
"vendor" : "HL-DT-ST",
"physid" : "0.0.0",
"businfo" : "scsi@2:0.0.0",
"logicalname" : ["/dev/cdrom", "/dev/cdrw", "/dev/dvd", "/dev/dvdrw", "/dev/sr0"],
"dev" : "11:0",
"version" : "FS05",
"configuration" : {
"ansiversion" : "5",
"status" : "nodisc"
},
"capabilities" : {
"removable" : "support is removable",
"audio" : "Audio CD playback",
"cd-r" : "CD-R burning",
"cd-rw" : "CD-RW burning",
"dvd" : "DVD playback",
"dvd-r" : "DVD-R burning",
"dvd-ram" : "DVD-RAM burning"
}
}
Should check if config.json is available if not should create it.
Traceback (most recent call last): File "main.py", line 7, in <module> import issues as issues File "/home/daniel/Documents/computerspende/issues.py", line 8, in <module> content = open("config.json").read() FileNotFoundError: [Errno 2] No such file or directory: 'config.json'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.