]> git.lizzy.rs Git - cheatdb.git/blob - utils/setup.py
Create utils folder
[cheatdb.git] / utils / setup.py
1 # Content DB
2 # Copyright (C) 2018  rubenwardy
3 #
4 # This program is free software: you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation, either version 3 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program.  If not, see <https://www.gnu.org/licenses/>.
16
17
18 import os, sys, datetime, inspect
19
20 if not "FLASK_CONFIG" in os.environ:
21         os.environ["FLASK_CONFIG"] = "../config.cfg"
22
23 delete_db = len(sys.argv) >= 2 and sys.argv[1].strip() == "-d"
24 create_db = not (len(sys.argv) >= 2 and sys.argv[1].strip() == "-o")
25 test_data = len(sys.argv) >= 2 and sys.argv[1].strip() == "-t" or not create_db
26
27 # Allow finding the `app` module
28 currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
29 parentdir = os.path.dirname(currentdir)
30 sys.path.insert(0,parentdir) 
31
32 from app.models import *
33 from app.utils import make_flask_user_password
34
35 def defineDummyData(licenses, tags, ruben):
36         ez = User("Shara")
37         ez.github_username = "Ezhh"
38         ez.forums_username = "Shara"
39         ez.rank = UserRank.EDITOR
40         db.session.add(ez)
41
42         not1 = Notification(ruben, ez, "Awards approved", "/packages/rubenwardy/awards/")
43         db.session.add(not1)
44
45         jeija = User("Jeija")
46         jeija.github_username = "Jeija"
47         jeija.forums_username = "Jeija"
48         db.session.add(jeija)
49
50
51         mod = Package()
52         mod.approved = True
53         mod.name = "alpha"
54         mod.title = "Alpha Test"
55         mod.license = licenses["MIT"]
56         mod.type = PackageType.MOD
57         mod.author = ruben
58         mod.tags.append(tags["mapgen"])
59         mod.tags.append(tags["environment"])
60         mod.repo = "https://github.com/ezhh/other_worlds"
61         mod.issueTracker = "https://github.com/ezhh/other_worlds/issues"
62         mod.forums = 16015
63         mod.short_desc = "The content library should not be used yet as it is still in alpha"
64         mod.desc = "This is the long desc"
65         db.session.add(mod)
66
67         rel = PackageRelease()
68         rel.package = mod
69         rel.title = "v1.0.0"
70         rel.url = "https://github.com/ezhh/handholds/archive/master.zip"
71         rel.approved = True
72         db.session.add(rel)
73
74         mod1 = Package()
75         mod1.approved = True
76         mod1.name = "awards"
77         mod1.title = "Awards"
78         mod1.license = licenses["LGPLv2.1"]
79         mod1.type = PackageType.MOD
80         mod1.author = ruben
81         mod1.tags.append(tags["player_effects"])
82         mod1.repo = "https://github.com/rubenwardy/awards"
83         mod1.issueTracker = "https://github.com/rubenwardy/awards/issues"
84         mod1.forums = 4870
85         mod1.short_desc = "Adds achievements and an API to register new ones."
86         mod1.desc = """
87 Majority of awards are back ported from Calinou's old fork in Carbone, under same license.
88
89 ```
90 awards.register_achievement("award_mesefind",{
91     title = "First Mese Find",
92     description = "Found some Mese!",
93     trigger = {
94         type   = "dig",          -- award is given when
95         node   = "default:mese", -- this type of node has been dug
96         target = 1,              -- this number of times
97     },
98 })
99 ```
100 """
101
102         rel = PackageRelease()
103         rel.package = mod1
104         rel.title = "v1.0.0"
105         rel.url = "https://github.com/rubenwardy/awards/archive/master.zip"
106         rel.approved = True
107         db.session.add(rel)
108
109         mod2 = Package()
110         mod2.approved = True
111         mod2.name = "mesecons"
112         mod2.title = "Mesecons"
113         mod2.tags.append(tags["tools"])
114         mod2.type = PackageType.MOD
115         mod2.license = licenses["LGPLv3"]
116         mod2.author = jeija
117         mod2.repo = "https://github.com/minetest-mods/mesecons/"
118         mod2.issueTracker = "https://github.com/minetest-mods/mesecons/issues"
119         mod2.forums = 628
120         mod2.short_desc = "Mesecons adds everything digital, from all kinds of sensors, switches, solar panels, detectors, pistons, lamps, sound blocks to advanced digital circuitry like logic gates and programmable blocks."
121         mod2.desc = """
122     ########################################################################
123     ##  __    __   _____   _____   _____   _____   _____   _   _   _____  ##
124     ## |  \  /  | |  ___| |  ___| |  ___| |  ___| |  _  | | \ | | |  ___| ##
125     ## |   \/   | | |___  | |___  | |___  | |     | | | | |  \| | | |___  ##
126     ## | |\__/| | |  ___| |___  | |  ___| | |     | | | | |     | |___  | ##
127     ## | |    | | | |___   ___| | | |___  | |___  | |_| | | |\  |  ___| | ##
128     ## |_|    |_| |_____| |_____| |_____| |_____| |_____| |_| \_| |_____| ##
129     ##                                                                    ##
130     ########################################################################
131
132 MESECONS by Jeija and contributors
133
134 Mezzee-what?
135 ------------
136 [Mesecons](http://mesecons.net/)! They're yellow, they're conductive, and they'll add a whole new dimension to Minetest's gameplay.
137
138 Mesecons is a mod for [Minetest](http://minetest.net/) that implements a ton of items related to digital circuitry, such as wires, buttons, lights, and even programmable controllers. Among other things, there are also pistons, solar panels, pressure plates, and note blocks.
139
140 Mesecons has a similar goal to Redstone in Minecraft, but works in its own way, with different rules and mechanics.
141
142 OK, I want in.
143 --------------
144 Go get it!
145
146 [DOWNLOAD IT NOW](https://github.com/minetest-mods/mesecons/archive/master.zip)
147
148 Now go ahead and install it like any other Minetest mod. Don't know how? Check out [the wonderful page about it](http://wiki.minetest.com/wiki/Mods) over at the Minetest Wiki. For your convenience, here's a quick summary:
149
150 1. If Mesecons is still in a ZIP file, extract the folder inside to somewhere on the computer.
151 2. Make sure that when you open the folder, you can directly find `README.md` in the listing. If you just see another folder, move that folder up one level and delete the old one.
152 3. Open up the Minetest mods folder - usually `/mods/`. If you see the `minetest` or folder inside of that, that is your mod folder instead.
153 4. Copy the Mesecons folder into the mods folder.
154
155 Don't like some parts of Mesecons? Open up the Mesecons folder and delete the subfolder containing the mod you don't want. If you didn't want movestones, for example, all you have to do is delete the `mesecons_movestones` folder and they will no longer be available.
156
157 There are no dependencies - it will work right after installing!
158
159 How do I use this thing?
160 ------------------------
161 How about a [quick overview video](https://www.youtube.com/watch?v=6kmeQj6iW5k)?
162
163 Or maybe a [comprehensive reference](http://mesecons.net/items.html) is your style?
164
165 An overview for the very newest of new beginners? How does [this one](http://uberi.mesecons.net/projects/MeseconsBasics/index.html) look?
166
167 Want to get more into building? Why not check out the [Mesecons Laboratory](http://uberi.mesecons.net/), a website dedicated to advanced Mesecons builders?
168
169 Want to contribute to Mesecons itself? Check out the [source code](https://github.com/minetest-mods/mesecons)!
170
171 Who wrote it anyways?
172 ---------------------
173 These awesome people made Mesecons possible!
174
175 | Contributor     | Contribution                     |
176 | --------------- | -------------------------------- |
177 | Hawk777         | Code for VoxelManip caching      |
178 | Jat15           | Various tweaks.                  |
179 | Jeija           | **Main developer! Everything.**  |
180 | Jordach         | Noteblock sounds.                |
181 | khonkhortistan  | Code, recipes, textures.         |
182 | Kotolegokot     | Nodeboxes for items.             |
183 | minerd247       | Textures.                        |
184 | Nore/Novatux    | Code.                            |
185 | RealBadAngel    | Fixes, improvements.             |
186 | sfan5           | Code, recipes, textures.         |
187 | suzenako        | Piston sounds.                   |
188 | Uberi/Temperest | Code, textures, documentation.   |
189 | VanessaE        | Code, recipes, textures, design. |
190 | Whiskers75      | Logic gates implementation.      |
191
192 There are also a whole bunch of other people helping with everything from code to testing and feedback. Mesecons would also not be possible without their help!
193
194 Alright, how can I use it?
195 --------------------------
196 All textures in this project are licensed under the CC-BY-SA 3.0 (Creative Commons Attribution-ShareAlike 3.0 Generic). That means you can distribute and remix them as much as you want to, under the condition that you give credit to the authors and the project, and that if you remix and release them, they must be under the same or similar license to this one.
197
198 All code in this project is licensed under the LGPL version 3 or later. That means you have unlimited freedom to distribute and modify the work however you see fit, provided that if you decide to distribute it or any modified versions of it, you must also use the same license. The LGPL also grants the additional freedom to write extensions for the software and distribute them without the extensions being subject to the terms of the LGPL, although the software itself retains its license.
199
200 No warranty is provided, express or implied, for any part of the project.
201
202 """
203
204         db.session.add(mod1)
205         db.session.add(mod2)
206
207         mod = Package()
208         mod.approved = True
209         mod.name = "handholds"
210         mod.title = "Handholds"
211         mod.license = licenses["MIT"]
212         mod.type = PackageType.MOD
213         mod.author = ez
214         mod.tags.append(tags["player_effects"])
215         mod.repo = "https://github.com/ezhh/handholds"
216         mod.issueTracker = "https://github.com/ezhh/handholds/issues"
217         mod.forums = 17069
218         mod.short_desc = "Adds hand holds and climbing thingies"
219         mod.desc = "This is the long desc"
220         db.session.add(mod)
221
222         rel = PackageRelease()
223         rel.package = mod
224         rel.title = "v1.0.0"
225         rel.url = "https://github.com/ezhh/handholds/archive/master.zip"
226         rel.approved = True
227         db.session.add(rel)
228
229         mod = Package()
230         mod.approved = True
231         mod.name = "other_worlds"
232         mod.title = "Other Worlds"
233         mod.license = licenses["MIT"]
234         mod.type = PackageType.MOD
235         mod.author = ez
236         mod.tags.append(tags["mapgen"])
237         mod.tags.append(tags["environment"])
238         mod.repo = "https://github.com/ezhh/other_worlds"
239         mod.issueTracker = "https://github.com/ezhh/other_worlds/issues"
240         mod.forums = 16015
241         mod.short_desc = "Adds space with asteroids and comets"
242         mod.desc = "This is the long desc"
243         db.session.add(mod)
244
245         mod = Package()
246         mod.approved = True
247         mod.name = "food"
248         mod.title = "Food"
249         mod.license = licenses["LGPLv2.1"]
250         mod.type = PackageType.MOD
251         mod.author = ruben
252         mod.tags.append(tags["player_effects"])
253         mod.repo = "https://github.com/rubenwardy/food/"
254         mod.issueTracker = "https://github.com/rubenwardy/food/issues/"
255         mod.forums = 2960
256         mod.short_desc = "Adds lots of food and an API to manage ingredients"
257         mod.desc = "This is the long desc"
258         food = mod
259         db.session.add(mod)
260
261         mod = Package()
262         mod.approved = True
263         mod.name = "food_sweet"
264         mod.title = "Sweet Foods"
265         mod.license = licenses["CC0"]
266         mod.type = PackageType.MOD
267         mod.author = ruben
268         mod.tags.append(tags["player_effects"])
269         mod.repo = "https://github.com/rubenwardy/food_sweet/"
270         mod.issueTracker = "https://github.com/rubenwardy/food_sweet/issues/"
271         mod.forums = 9039
272         mod.short_desc = "Adds sweet food"
273         mod.desc = "This is the long desc"
274         food_sweet = mod
275         db.session.add(mod)
276
277         game1 = Package()
278         game1.approved = True
279         game1.name = "capturetheflag"
280         game1.title = "Capture The Flag"
281         game1.type = PackageType.GAME
282         game1.license = licenses["LGPLv2.1"]
283         game1.author = ruben
284         game1.tags.append(tags["pvp"])
285         game1.tags.append(tags["survival"])
286         game1.tags.append(tags["multiplayer"])
287         game1.repo = "https://github.com/rubenwardy/capturetheflag"
288         game1.issueTracker = "https://github.com/rubenwardy/capturetheflag/issues"
289         game1.forums = 12835
290         game1.short_desc = "Two teams battle to snatch and return the enemy's flag, before the enemy takes their own!"
291         game1.desc = """
292 As seen on the Capture the Flag server (minetest.rubenwardy.com:30000)
293
294 Uses the CTF PvP Engine.
295 """
296
297         db.session.add(game1)
298
299         rel = PackageRelease()
300         rel.package = game1
301         rel.title = "v1.0.0"
302         rel.url = "https://github.com/rubenwardy/capturetheflag/archive/master.zip"
303         rel.approved = True
304         db.session.add(rel)
305
306
307         mod = Package()
308         mod.approved = True
309         mod.name = "pixelbox"
310         mod.title = "PixelBOX Reloaded"
311         mod.license = licenses["CC0"]
312         mod.type = PackageType.TXP
313         mod.author = ruben
314         mod.forums = 14132
315         mod.short_desc = "This is an update of the original PixelBOX texture pack by the brillant artist Gambit"
316         mod.desc = "This is the long desc"
317         db.session.add(mod)
318
319         rel = PackageRelease()
320         rel.package = mod
321         rel.title = "v1.0.0"
322         rel.url = "http://mamadou3.free.fr/Minetest/PixelBOX.zip"
323         rel.approved = True
324         db.session.add(rel)
325
326         db.session.commit()
327
328         metas = {}
329         for package in Package.query.filter_by(type=PackageType.MOD).all():
330                 meta = None
331                 try:
332                         meta = metas[package.name]
333                 except KeyError:
334                         meta = MetaPackage(package.name)
335                         db.session.add(meta)
336                         metas[package.name] = meta
337                 package.provides.append(meta)
338
339         dep = Dependency(food_sweet, meta=metas["food"])
340         db.session.add(dep)
341
342
343 if delete_db and os.path.isfile("db.sqlite"):
344         os.remove("db.sqlite")
345
346
347 if create_db:
348         print("Creating database tables...")
349         db.create_all()
350
351 print("Filling database...")
352
353 ruben = User("rubenwardy")
354 ruben.active = True
355 ruben.password = make_flask_user_password("tuckfrump")
356 ruben.github_username = "rubenwardy"
357 ruben.forums_username = "rubenwardy"
358 ruben.rank = UserRank.ADMIN
359 db.session.add(ruben)
360
361 tags = {}
362 for tag in ["Inventory", "Mapgen", "Building", \
363                 "Mobs and NPCs", "Tools", "Player effects", \
364                 "Environment", "Transport", "Maintenance", "Plants and farming", \
365                 "PvP", "PvE", "Survival", "Creative", "Puzzle", "Multiplayer", "Singleplayer"]:
366         row = Tag(tag)
367         tags[row.name] = row
368         db.session.add(row)
369
370 licenses = {}
371 for license in ["GPLv2.1", "GPLv3", "LGPLv2.1", "LGPLv3", "AGPLv2.1", "AGPLv3",
372                                 "Apache", "BSD 3-Clause", "BSD 2-Clause", "CC0", "CC-BY-SA",
373                                 "CC-BY", "MIT", "ZLib", "Other (Free)"]:
374         row = License(license)
375         licenses[row.name] = row
376         db.session.add(row)
377
378 for license in ["CC-BY-NC-SA", "Other (Non-free)"]:
379         row = License(license, False)
380         licenses[row.name] = row
381         db.session.add(row)
382
383 if test_data:
384         defineDummyData(licenses, tags, ruben)
385
386 db.session.commit()