diff options
author | jwansek <eddie.atten.ea29@gmail.com> | 2022-05-07 21:04:34 +0000 |
---|---|---|
committer | jwansek <eddie.atten.ea29@gmail.com> | 2022-05-07 21:04:34 +0000 |
commit | 0a6a4956fe44ed77dba32ace075a185ac16a4ad3 (patch) | |
tree | 3e58629b7ec104c07f2d10581691ea6eddf62141 | |
parent | 022fa3780ad63b49cb50c1482aa1d598e27feac5 (diff) | |
download | eda.gay-0a6a4956fe44ed77dba32ace075a185ac16a4ad3.tar.gz eda.gay-0a6a4956fe44ed77dba32ace075a185ac16a4ad3.zip |
Changed the ISO ordering system
-rw-r--r-- | database.py | 26 | ||||
-rw-r--r-- | docker-compose.yml | 1 | ||||
-rwxr-xr-x | hardware.md | 56 | ||||
-rw-r--r-- | requirements.txt | 2 | ||||
-rw-r--r-- | services.py | 22 | ||||
-rw-r--r-- | templates/isocd.jinja | 1 |
6 files changed, 23 insertions, 85 deletions
diff --git a/database.py b/database.py index 61ca2f7..ee3e3f0 100644 --- a/database.py +++ b/database.py @@ -17,20 +17,20 @@ class Database: passwd:str = None def __enter__(self): - config = configparser.ConfigParser() - config.read("edaweb.conf") + self.config = configparser.ConfigParser() + self.config.read("edaweb.conf") if self.safeLogin: self.__connection = pymysql.connect( - **config["mysql"], + **self.config["mysql"], charset = "utf8mb4" ) else: self.__connection = pymysql.connect( user = self.user, passwd = self.passwd, - host = config["mysql"]["host"], - db = config["mysql"]["db"], + host = self.config["mysql"]["host"], + db = self.config["mysql"]["db"], charset = "utf8mb4" ) return self @@ -184,15 +184,19 @@ class Database: return cursor.fetchone()[0] def get_iso_cd_options(self): - with self.__connection.cursor() as cursor: - cursor.execute("SELECT name FROM isocds;") - return [i[0] for i in cursor.fetchall()] + iso_dir = self.config.get("cds", "location") + return [ + i + for i in os.listdir(iso_dir) + if os.path.splitext(i)[-1].lower() in [".iso"] + and os.path.getsize(os.path.join(iso_dir, i)) < self.config.getint("cds", "maxsize") + ] def append_cd_orders(self, iso, email, house, street, city, county, postcode, name): with self.__connection.cursor() as cursor: cursor.execute(""" - INSERT INTO cd_orders (cd_id, email, house, street, city, county, postcode, name) - VALUES ((SELECT cd_id FROM isocds WHERE name = %s), %s, %s, %s, %s, %s, %s, %s); + INSERT INTO cd_orders_2 (iso, email, house, street, city, county, postcode, name) + VALUES (%s, %s, %s, %s, %s, %s, %s, %s); """, (iso, email, house, street, city, county, postcode, name)) id_ = cursor.lastrowid self.__connection.commit() @@ -250,4 +254,4 @@ if __name__ == "__main__": import parser with Database() as db: # print(db.get_similar_thoughts("about me", 5)) - print(parser.parse_file("out.md")) + print(db.get_iso_cd_options()) diff --git a/docker-compose.yml b/docker-compose.yml index 57b8167..27e48f2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,6 +6,7 @@ services: dockerfile: Dockerfile image: jwansek/edaweb volumes: + - /media/ISOs/:/media/ISOs/ - ./static/:/app/static/ - ./edaweb.conf:/app/edaweb.conf ports: diff --git a/hardware.md b/hardware.md deleted file mode 100755 index 53a8fd1..0000000 --- a/hardware.md +++ /dev/null @@ -1,56 +0,0 @@ -# general computing -- my main computer that i do most of my work on is a thinkpad x260. it has a [6500U cpu](https://eda.gay/thought?id=13#Intel+i7-6500u) and 8Gb of ram. it runs debian unstable, manjaro and windows for when i need to use shitty proprietary software -- i also use a [thinkpad x200](https://eda.gay/thought?id=13#Intel+Core+2+Duo+P8400). it has an amazing keyboard so its great for writing latex documents. it's librebooted and has no proprietary software at all on it. it runs debian unstable too :3 - -  - -me flashing the bios to libreboot with a raspberry pi - -# games etc -i have a small form factor dell optiplex 3060 with an [8500T cpu](https://eda.gay/thought?id=13#Intel+Core+i5-8500T) with 16Gb of memory. its useful to have a windows computer laying about that i can play games with my friends on - -# server(s) - - -here it is! server racks are very expensive, so i'm using a [lackrack](https://wiki.eth0.nl/index.php/LackRack) instead. from top to bottom there is: - -0. on top there is a [thinkpad t30](https://eda.gay/thought?id=13#Intel+Mobile+Pentium+4-M+1.8+GHz) being used as a CUPS print server. it is connected to a Star LC-10 dot matrix printer. i use the old t30 for this since its the only computer i have with a parallel port. [here's a video of the really old printer running.](https://nc.eda.gay/s/HbbCmCZdFJHmHAB) also there is a dock for the x200. finally a keyboard for the top kvm switch and a couple game controllers. -1. a shitty old vga/PS2 kvm switch. connected to it are the raspberry pis, the nas, and the print server (stuff i dont need to access often) -2. a startech 4 port dual monitor kvm switch (SV431DD2DUA). connected to it are the dell optiplex, the x260 dock, the x200 dock, and the fedora 1u. -3. the first shelf has a Netgear GS108PE POE switch which powers 3x raspberry pis and the other switch. there's also a hard drive behind for backups and the dell optiplex 3060 windows pc. -4. a brush cable management thingy -5. Mikrotik CSS610-8G-2S+in 10gig switch, 3x raspberry pi 3bs, and a dvd drive connected to the server below. one of the raspberry pis is a torrent client and the other is my DNS server, using unbound and pihole. it also does database backups, and is also my git server. the third one is still being setup. -6. a 1u server. its gonna be a pfsense router later, but for now it runs fedora workstation. it has an [AMD A4-5000](https://eda.gay/thought?id=13#AMD+A4-5000) 15W quad core CPU with hardware AES. It has 8Gb of memory and a powerful intel i350 dual port nic. -7. below is my main server/nas. it has an [i5-9400t](https://eda.gay/thought?id=13#Intel+Core+i5-9400T) 6 core cpu. i went with the t version since it has a lower tdp and therefore it is cheaper to run. it runs truenas (formerly called freenas). it also runs all of my docker containers on a ubuntu server VM. it has 32gb of memory for a nice big zfs cache and is potentially upgradeable to 64gb. it has a passive cooler for quietness. click [here](https://eda.gay/services) to see what's running on the server. - - - -dual port 10 gigabit network card i got for only £25 - -> be me -> buy low tdp cpu to save money on electricity bills -> also be me -> install network card that draws 15w -> has to cable tie a fan to it so it doesnt turn into lava - -  - -a better pic of the two switches - plus my new POE one I will be switching too soon! - - - -the back of the startech kvm switch - some serious i/o porn! plus my old shitty dumb switch on top - - - -current *gamer* router my roomie bought. it has loads of cool features, but doesnt have network boot :(. it runs an openvpn server for when my wireguard server is broken. - - - -the 1u machine in rack space 6 that will be my pfsense router next year. currently it just runs fedora for some backup stuff. despite having two small fans it is surprisingly quiet. - -# the next generation - -here's what im working on now- a brand new (real rack) with a new xeon server! - -  diff --git a/requirements.txt b/requirements.txt index 90f647f..b09cc1c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,7 +1,7 @@ itsdangerous==2.0.1 PyMySQL==1.0.2 python_qbittorrent==0.4.2 -Flask==1.1.2 +Flask==2.1.0 PiHole_api transmission-clutch dataclasses diff --git a/services.py b/services.py index 51ab6a1..681c82a 100644 --- a/services.py +++ b/services.py @@ -18,12 +18,6 @@ import os theLastId = 0 -def get_isos(iso_dir): - print(os.path.exists(iso_dir)) - return [ - i for i in os.listdir(iso_dir) - ] - def humanbytes(B): 'Return the given bytes as a human friendly KB, MB, GB, or TB string' B = float(B) @@ -234,14 +228,8 @@ def link_deleted(url): return text[text.find("<title>") + 7 : text.find("</title>")] in ["Error | nitter", "イラストコミュニケーションサービス[pixiv]"] if __name__ == "__main__": - # sbi = get_random_image(["lio_fotia", "promare"]) - # print(sbi.tags) - # print(sbi.source) - # print(sbi.imurl) - # print(sbi.remove_tag("promare")) - - import configparser - CONFIG = configparser.ConfigParser() - CONFIG.read("edaweb.conf") - - print(get_isos(CONFIG.get("cds", "location")))
\ No newline at end of file + sbi = get_random_image(["lio_fotia", "promare"]) + print(sbi.tags) + print(sbi.source) + print(sbi.imurl) + print(sbi.remove_tag("promare")) diff --git a/templates/isocd.jinja b/templates/isocd.jinja index da7a737..ee8ac61 100644 --- a/templates/isocd.jinja +++ b/templates/isocd.jinja @@ -10,6 +10,7 @@ <option value="{{ iso }}">{{ iso }}</option> {% endfor %} </select><br><br> + <p>Sadly there is an upper limit on ISOs of 700Mb coz thats what u can fit on a cd ;_; so big isos arent listed</p><br> <label for="name">*Name:</label> <input id="name" name="name" required><br><br> <label for="house">*House Number/Name:</label> |