Initial Commit
This commit is contained in:
0
bin/config/case.py
Normal file
0
bin/config/case.py
Normal file
0
bin/config/cooler.py
Normal file
0
bin/config/cooler.py
Normal file
0
bin/config/cpu.py
Normal file
0
bin/config/cpu.py
Normal file
0
bin/config/gpu.py
Normal file
0
bin/config/gpu.py
Normal file
0
bin/config/hdd.py
Normal file
0
bin/config/hdd.py
Normal file
0
bin/config/mbd.py
Normal file
0
bin/config/mbd.py
Normal file
0
bin/config/os.py
Normal file
0
bin/config/os.py
Normal file
0
bin/config/psu.py
Normal file
0
bin/config/psu.py
Normal file
0
bin/config/ssd.py
Normal file
0
bin/config/ssd.py
Normal file
34
bin/config/userprofile_creator.py
Normal file
34
bin/config/userprofile_creator.py
Normal file
@@ -0,0 +1,34 @@
|
||||
"""@package docstring
|
||||
This module asks the user questions so the software can configure the PC.
|
||||
"""
|
||||
|
||||
|
||||
class UserprofileCreator:
|
||||
def __init__(self):
|
||||
print("""First of all we need your name so we can match it with you.""")
|
||||
self.i = 0
|
||||
|
||||
def chg_username(self):
|
||||
self.i = input("please enter your name")
|
||||
return self.i
|
||||
|
||||
def chg_budget(self):
|
||||
self.i = input("Now, how big is your budget? ")
|
||||
return self.i
|
||||
|
||||
def chg_use_case(self):
|
||||
""""""
|
||||
print("""Now we need some information regarding your intended use-case for this system.
|
||||
o = Office-PC (you are editing documents, creating pdfs, browsing the web
|
||||
c = Content Creation PC (you are editing videos, editing photos or other similarly intense workloads
|
||||
g = Gaming-PC (You are playing games, maybe streaming as well?)
|
||||
""")
|
||||
self.i = input("Choose your use-case from above")
|
||||
return self.i
|
||||
|
||||
def chg_os(self):
|
||||
print("""simplePCBuilding offers the installation of different Operating Systems. You can choose from
|
||||
following:
|
||||
W10 = Windows 10
|
||||
W11 = Windows 11
|
||||
L = any Linux-Distro""")
|
||||
65
bin/lib/csv_parsers.py
Normal file
65
bin/lib/csv_parsers.py
Normal file
@@ -0,0 +1,65 @@
|
||||
"""@package docstring
|
||||
This is a simplification of the csv module"""
|
||||
|
||||
import csv
|
||||
|
||||
|
||||
class CsvRead:
|
||||
"""This is a class that reads csv files and depending on the module selected does do different things with it"""
|
||||
def __init__(self):
|
||||
self.__imp = ""
|
||||
self.__raw = ""
|
||||
self.__raw_list = ""
|
||||
|
||||
def importing(self, path):
|
||||
"""Returns a list of the imported csv-file, requires path, either direct system path or relative path"""
|
||||
self.__imp = open(path)
|
||||
self.__raw = csv.reader(self.__imp, delimiter=',')
|
||||
self.__raw_list = list(self.__raw)
|
||||
return self.__raw_list
|
||||
|
||||
|
||||
class CsvWrite:
|
||||
"""This is a class that modifies csv files"""
|
||||
def __init__(self):
|
||||
self.__impl = []
|
||||
self.__strpop = []
|
||||
self.__removed = []
|
||||
self.__removing = 0
|
||||
self.__change = 0
|
||||
self.__appending = 0
|
||||
|
||||
def rem_str(self, path, row):
|
||||
"""Opens the csv-file in write mode which is specified as an argument either as direct or relative path"""
|
||||
self.__impl = CsvRead.importing(path)
|
||||
self.__removed = self.__impl.pop(row)
|
||||
with open(path, "w") as removedata:
|
||||
self.__removing = csv.writer(removedata, delimiter=',', quoting=csv.QUOTE_MINIMAL)
|
||||
self.__removing.writerow(self.__removed)
|
||||
|
||||
def chg_str(self, path, row, pos, new_value):
|
||||
"""Opens the csv-file in write mode to change a value, e.g. if a recipes is changed."""
|
||||
self.__impl = CsvRead.importing(path)
|
||||
self.__strpop = self.__impl.pop(row)
|
||||
self.__strpop.remove(pos)
|
||||
self.__strpop.insert(pos, new_value)
|
||||
self.__impl.insert(row, self.__strpop)
|
||||
with open(path, "w") as changedata:
|
||||
self.__change = csv.writer(changedata, delimiter=',', quoting=csv.QUOTE_MINIMAL)
|
||||
self.__change.writerow(self.__impl)
|
||||
|
||||
def app_str(self, path, value):
|
||||
"""Opens the csv-file in append mode and writes given input. CsvWrite.app_str(path, value).
|
||||
Path can be specified both as direct or relative. value is a list. Will return an error if type of value is
|
||||
not a list."""
|
||||
with open(path, "a") as appenddata:
|
||||
self.__appending = csv.writer(appenddata, delimiter=',', quoting=csv.QUOTE_MINIMAL)
|
||||
self.__appending.writerow(value)
|
||||
|
||||
def initialize(self):
|
||||
with open("../../data/ingredients/ingredients.csv", "w") as initializedata:
|
||||
self.__creating = csv.writer(initializedata, delimiter=',', quoting=csv.QUOTE_MINIMAL)
|
||||
self.__creating.writerow(["Setup-Success"])
|
||||
with open("../../data/recipes/recipes.csv", "w") as initializedata:
|
||||
self.__creating = csv.writer(initializedata, delimiter=',', quoting=csv.QUOTE_MINIMAL)
|
||||
self.__creating.writerow(["Setup-Success"])
|
||||
18
bin/modules/configurator.py
Normal file
18
bin/modules/configurator.py
Normal file
@@ -0,0 +1,18 @@
|
||||
"""@package docstring
|
||||
This module configures PCs but relies heavily on external modules that are included with the package.
|
||||
"""
|
||||
|
||||
|
||||
class ConfigCreator:
|
||||
def __init__(self):
|
||||
print("""
|
||||
|
||||
|
||||
|
||||
Welcome to the PC-Configurator!
|
||||
--------------------------------
|
||||
|
||||
We still need a couple of informations so we can make sure you get the best configuration possible!
|
||||
|
||||
No more questions? Let's start!
|
||||
""")
|
||||
0
bin/modules/updater.py
Normal file
0
bin/modules/updater.py
Normal file
36
bin/package_manager/backend/componentmanager.py
Normal file
36
bin/package_manager/backend/componentmanager.py
Normal file
@@ -0,0 +1,36 @@
|
||||
from kivy.app import App
|
||||
from kivy.lang import Builder
|
||||
from kivy.uix.screenmanager import Screen, ScreenManager
|
||||
from kivy.uix.popup import Popup
|
||||
|
||||
|
||||
class MainScreen(Screen):
|
||||
pass
|
||||
|
||||
|
||||
class AddComponent(Screen):
|
||||
pass
|
||||
|
||||
|
||||
class ModifyComponent(Screen):
|
||||
pass
|
||||
|
||||
|
||||
class RemoveComponent(Screen):
|
||||
pass
|
||||
|
||||
|
||||
class RootScreen(ScreenManager):
|
||||
pass
|
||||
|
||||
|
||||
kv = Builder.load_file("../gui/gui.kv")
|
||||
|
||||
|
||||
class ComponentManager(App):
|
||||
def build(self):
|
||||
return kv
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
ComponentManager().run()
|
||||
55
bin/package_manager/backend/package_managing.py
Normal file
55
bin/package_manager/backend/package_managing.py
Normal file
@@ -0,0 +1,55 @@
|
||||
import datetime
|
||||
import csv
|
||||
"""@package docstring
|
||||
This software / package is used to easily manage the available products. This software will automatically update
|
||||
whenever there is an update for the reader available on the website.
|
||||
--------
|
||||
|
||||
NOTE: This software changes files in the directory in which it is located and as such is not made for
|
||||
inexperienced users. Please read the readme.txt file for further notice.
|
||||
|
||||
NOTE: This software does not feature a standard gui (Graphical User Interface) currently and as such is
|
||||
based on commands. You cna find a full lists of commands on the wiki.
|
||||
|
||||
NOTE: The simplePCBuilding-Configurator comes with an Update service for the component list. In the event of
|
||||
an Update, there is a script installed with your software that merges the new updates to the components file
|
||||
with the changes you made.
|
||||
|
||||
NOTE: Changing the CSV-File containing the component information with any other editor other than this one,
|
||||
the file might get unreadable for the software. Do always use this software here to change something.
|
||||
"""
|
||||
version = str("alpha 1.0")
|
||||
print("""
|
||||
================================================================
|
||||
Welcome to the simplePCBuilding PC-Configurator-Package-Manager!
|
||||
You are currently running""", version, """!
|
||||
================================================================
|
||||
|
||||
This software is used to easily manage the available products. This software will automatically update
|
||||
whenever there is an update for the reader available on the website.
|
||||
--------
|
||||
|
||||
NOTE: This software changes files in the directory in which it is located and as such is not made for
|
||||
inexperienced users. Please read the readme.txt file for further notice.
|
||||
|
||||
NOTE: This software does not feature a standard gui (Graphical User Interface) currently and as such is
|
||||
based on commands. You cna find a full lists of commands on the wiki.
|
||||
|
||||
NOTE: The simplePCBuilding-Configurator comes with an Update service for the component list. In the event of
|
||||
an Update, there is a script installed with your software that merges the new updates to the components file
|
||||
with the changes you made.
|
||||
|
||||
NOTE: Changing the CSV-File containing the component information with any other editor other than this one,
|
||||
might result in loss of correct operation of the software. Do always use this software here to change something.
|
||||
""")
|
||||
|
||||
|
||||
|
||||
i = input("Please read above carefully and type a y to continue, a \"n\" to exit the software:")
|
||||
|
||||
if i == "y":
|
||||
print("Starting...")
|
||||
|
||||
else:
|
||||
print("Leaving...")
|
||||
|
||||
57
bin/package_manager/gui/gui.kv
Normal file
57
bin/package_manager/gui/gui.kv
Normal file
@@ -0,0 +1,57 @@
|
||||
RootScreen:
|
||||
MainScreen:
|
||||
AddComponent:
|
||||
RemoveComponent:
|
||||
ModifyComponent:
|
||||
|
||||
<MainScreen>:
|
||||
name: "Main"
|
||||
GridLayout:
|
||||
cols:1
|
||||
Label:
|
||||
text: "Welcome to the simplePCBuilding\n PC-Configuration-Suite\n Component-Manager!"
|
||||
font_size:30
|
||||
color: (0,0,1,0.6)
|
||||
FloatLayout:
|
||||
GridLayout:
|
||||
size_hint: 0.9, 0.9
|
||||
pos_hint:{"x":0.05, "y":0.05}
|
||||
cols:3
|
||||
Button:
|
||||
text: "New Component"
|
||||
on_release:
|
||||
app.root.current = "NewComp"
|
||||
root.manager.transition.direction = "right"
|
||||
Button:
|
||||
text: "Modify Component"
|
||||
on_release:
|
||||
app.root.current = "ModComp"
|
||||
root.manager.transition.direction = "down"
|
||||
Button:
|
||||
text: "Remove Component"
|
||||
on_release:
|
||||
app.root.current = "RemComp"
|
||||
root.manager.transition.direction = "left"
|
||||
|
||||
<AddComponent>:
|
||||
name: "NewComp"
|
||||
GridLayout:
|
||||
cols:1
|
||||
Label:
|
||||
text: "New Component"
|
||||
|
||||
<ModifyComponent>:
|
||||
name: "ModComp"
|
||||
GridLayout:
|
||||
cols:1
|
||||
Label:
|
||||
text: "Modify Component"
|
||||
|
||||
|
||||
<RemoveComponent>:
|
||||
name: "RemComp"
|
||||
GridLayout:
|
||||
cols:1
|
||||
Label:
|
||||
text: "Remove Component"
|
||||
|
||||
90
bin/price_extractor/price_extractor_objectoriented.py
Normal file
90
bin/price_extractor/price_extractor_objectoriented.py
Normal file
@@ -0,0 +1,90 @@
|
||||
"""@package docstring
|
||||
This package extracts prices from websites. Currently, the package only allows for extraction of prices from
|
||||
https://digitec.ch/"""
|
||||
|
||||
import requests
|
||||
import csv
|
||||
import datetime
|
||||
|
||||
|
||||
class PriceExtractor:
|
||||
def __init__(self):
|
||||
with open("../../data/prices.csv", "w") as pricedata:
|
||||
self.__writing = csv.writer(pricedata, delimiter=',', quoting=csv.QUOTE_MINIMAL)
|
||||
self.__writing.writerow(["version from", datetime.datetime.now()])
|
||||
self.__imp = open("../../data/products.csv", "r")
|
||||
self.__raw_imp = csv.reader(self.__imp, delimiter=',')
|
||||
self.__raw_list = list(self.__raw_imp)
|
||||
self.__productcount = len(self.__raw_list)
|
||||
print("needing to update", self.__productcount, "prices")
|
||||
self.__productnumber = 0
|
||||
self.__website = ""
|
||||
self.__ingest = ""
|
||||
self.__res = ""
|
||||
self.__priceIdx = 0
|
||||
self.__check = 0
|
||||
self.__request_done = ""
|
||||
self.__raw_price = ""
|
||||
self.__price = 0
|
||||
self.__price_extract = 0
|
||||
|
||||
def readfile(self, filename):
|
||||
"""Reads a new file that contains links in csv format. Arguments:
|
||||
Filename. Either specify full path (e.g. /home/[username]/price_extractor/prices.csv), relative path when
|
||||
inside the folder of the executable (e.g. /pricedata/prices2.csv) or inside another folder that is located in
|
||||
the parent folder (e.g. ../pricedata/prices3.csv).
|
||||
Returns the content of the file inside of a list.
|
||||
|
||||
Example: prices = PriceExtractor.readfile(/pricedata/prices2.csv) (NOTE: prices is a list in this case!)"""
|
||||
with open(filename, "w") as pricedata:
|
||||
self.__writing = csv.writer(pricedata, delimiter=',', quoting=csv.QUOTE_MINIMAL)
|
||||
self.__writing.writerow(["version from", datetime.datetime.now()])
|
||||
self.__imp = open("../../data/products.csv", "r")
|
||||
self.__raw_imp = csv.reader(self.__imp, delimiter=',')
|
||||
self.__raw_list = list(self.__raw_imp)
|
||||
self.__productcount = len(self.__raw_list)
|
||||
print("needing to update", self.__productcount, "prices")
|
||||
self.__productnumber = 0
|
||||
return self.__raw_list
|
||||
|
||||
def chg_website(self, website):
|
||||
"""Change the website (exact URL to product on https://digitec.ch/ only currently). Arguments:
|
||||
Website. Only put direct link to product on digitec. Will return an error if a link other than digitec is
|
||||
specified, though might work if the website structure is similar.
|
||||
|
||||
Example: PriceExtractor.chg_website(https://www.digitec.ch/de/s1/product/asus-radeon-rx-6600-dual-8-gb-grafikkarte-16833213)"""
|
||||
self.__website = website
|
||||
|
||||
def digitec_extractor(self):
|
||||
"""Run through the entire list of links specified in the csv file that was selected either when loading the
|
||||
function or when specified through the method \"readfile\". NOTE: This method does not require any additional
|
||||
arguments and also does run through the entire file!"""
|
||||
while self.__productnumber < self.__productcount:
|
||||
self.__ingest = self.__raw_list.pop(0)
|
||||
self.__website = self.__ingest.pop(1)
|
||||
self.__productnumber = int(self.__ingest.pop(0))
|
||||
print("fetching data... This step might take a couple of seconds")
|
||||
self.__res = requests.get(self.__website)
|
||||
print("recieved data from", self.__website)
|
||||
self.__check = str(self.__res)
|
||||
if self.__check == "<Response [404]>":
|
||||
print("Ressource unavailable, skipping..")
|
||||
else:
|
||||
self.__request_done = self.__res.text
|
||||
self.__priceIdx = self.__request_done.index('property="product:price:amount')
|
||||
self.__raw_price = self.__request_done[self.__priceIdx + 41:self.__priceIdx + 60]
|
||||
self.__price_extract = ""
|
||||
for buchstabe in self.__raw_price:
|
||||
if buchstabe == "\"":
|
||||
break
|
||||
else:
|
||||
self.__price_extract += buchstabe
|
||||
self.__price = float(self.__price_extract)
|
||||
print("The price is following: ", self.__price, "CHF\n")
|
||||
with open("../../data/prices.csv", "a") as pricedata:
|
||||
writing = csv.writer(pricedata, delimiter=',', quoting=csv.QUOTE_MINIMAL)
|
||||
writing.writerow([self.__productnumber, self.__price])
|
||||
|
||||
|
||||
digitec_ext = PriceExtractor()
|
||||
digitec_ext.digitec_extractor()
|
||||
45
bin/price_extractor/price_scrapper_v2.py
Normal file
45
bin/price_extractor/price_scrapper_v2.py
Normal file
@@ -0,0 +1,45 @@
|
||||
import bin.lib.csv_parsers
|
||||
import requests
|
||||
import datetime
|
||||
|
||||
cvr = bin.lib.csv_parsers.CsvRead()
|
||||
cvw = bin.lib.csv_parsers.CsvWrite()
|
||||
|
||||
class PriceExtractor:
|
||||
def __init__(self):
|
||||
|
||||
def update_all_prices(self, folder):
|
||||
self.digitec_extractor()
|
||||
|
||||
|
||||
def digitec_extractor(self):
|
||||
"""Run through the entire list of links specified in the csv file that was selected either when loading the
|
||||
function or when specified through the method \"readfile\". NOTE: This method does not require any additional
|
||||
arguments and also does run through the entire file!"""
|
||||
while
|
||||
|
||||
while self.__productnumber < self.__productcount:
|
||||
self.__ingest = self.__raw_list.pop(0)
|
||||
self.__website = self.__ingest.pop(1)
|
||||
self.__productnumber = int(self.__ingest.pop(0))
|
||||
print("fetching data... This step might take a couple of seconds")
|
||||
self.__res = requests.get(self.__website)
|
||||
print("recieved data from", self.__website)
|
||||
self.__check = str(self.__res)
|
||||
if self.__check == "<Response [404]>":
|
||||
print("Ressource unavailable, skipping..")
|
||||
else:
|
||||
self.__request_done = self.__res.text
|
||||
self.__priceIdx = self.__request_done.index('property="product:price:amount')
|
||||
self.__raw_price = self.__request_done[self.__priceIdx + 41:self.__priceIdx + 60]
|
||||
self.__price_extract = ""
|
||||
for buchstabe in self.__raw_price:
|
||||
if buchstabe == "\"":
|
||||
break
|
||||
else:
|
||||
self.__price_extract += buchstabe
|
||||
self.__price = float(self.__price_extract)
|
||||
print("The price is following: ", self.__price, "CHF\n")
|
||||
with open("../../data/prices.csv", "a") as pricedata:
|
||||
writing = csv.writer(pricedata, delimiter=',', quoting=csv.QUOTE_MINIMAL)
|
||||
writing.writerow([self.__productnumber, self.__price])
|
||||
Reference in New Issue
Block a user