Compare commits

...

3 Commits

Author SHA1 Message Date
7286d2d460 read me 2019-06-02 19:04:12 -04:00
7ac8c364d1 added post_pack() to master 2019-06-02 18:56:52 -04:00
508b2781f1 add index page to server post() 2019-06-02 18:26:07 -04:00
4 changed files with 45 additions and 4 deletions

View File

@ -6,11 +6,12 @@ Python 3.6+
#### Master
Python packages: `requests bs4`
#### Server
Python packages: `flask passlib argon2_cffi`
Python packages: `flask gunicorn passlib argon2_cffi`
#### Slave
Python packages: ` `
## Usage
### Master
`$ python3 overwrought_master.py action [options] [target]`
__actions__
* `add` Add a new mod to the modpack. `target` must be a url to a curseforge mod project page. By default, it will prioritize release phases as Release, Beta and then Alpha. `--phase` can alter this. Will always grab the latest version of whichever phase it targets.
@ -18,3 +19,5 @@ __actions__
* `update` Update a specific mod in the modpack. `target` must be the url associated with the mod. By default, it will prioritize the release phase previously added. `--phase` can alter this. Will only update if the targeted mod is more recent than the one previously downloaded.
* `update_all` Update every mod in the modpack. No `target` needed. Will prioritize release phases similar to `update`, however `--phase` will will not affect it.
* `summary` Generate a summary page as html. Summary page displays a list of all mods in the modpack and a change log that is updated as changes are made to the modpack.
### Server
`gunicorn -b localhost:5000 -e SCRIPT_NAME=/overwrought overwrought_server:app`

View File

@ -4,6 +4,10 @@ Configuration settings for overwrought_master.py.
`mc_ver` is used literally when searching for an appropriate verison of
a mod to download. Should not include the minor version.
`modpack_name` is used for vanity purposes when naming the modpack.
`password` is the password used for uploading to the remote server.
`remote_addr` is the address of the remote Overwrought server.
"""
mc_ver = "1.12"
modpack_name = "motherlode1"
password = r"""PASSWORD"""
remote_addr = "https://stream.steelbea.me/overwrought"

View File

@ -4,7 +4,6 @@ A script for updating mods in a minecraft modpack.
"""
import os
import re
import json
import sqlite3
from datetime import datetime
@ -241,6 +240,36 @@ def generate_summary():
file.write(html)
def post_pack():
"""
Uploads the modpack to the remote server.
"""
data = {'password': config_master.password}
mods = get_all_mods()
res = requests.get(config_master.remote_addr + '/get')
res.raise_for_status()
mods_remote = res.json()
mods = [mod for mod in mods if mod.filename not in mods_remote]
files = {}
for mod in mods:
files[mod.filename] = open(os.path.join('mods', mod.filename), 'rb')
files[config_master.modpack_name + '.html'] = open(
config_master.modpack_name, 'rb')
res = requests.post(
url=config_master.remote_addr + '/post',
data=data,
files=files
)
res.raise_for_status()
for file in files.values():
file.close()
print('Success!')
if __name__ == "__main__":
import argparse
@ -250,7 +279,7 @@ if __name__ == "__main__":
)
parser.add_argument(
"action",
choices=["add", "add_all", "update", "update_all", "summary"],
choices=["add", "add_all", "update", "update_all", "summary", "post"],
help="What action to perform.",
)
parser.add_argument(
@ -284,3 +313,5 @@ if __name__ == "__main__":
update_mod_all(args.delete)
elif args.action == "summary":
generate_summary()
elif args.action == "post":
post_pack()

View File

@ -52,8 +52,11 @@ def post():
db.save('modpack.db')
app.config.get('db_lock').release()
summary = request.files.get(config_server.modpack_name + '.html')
summary.save(config_server.modpack_name + '.html')
for fname, file in request.files.items():
if fname == 'modpack.db':
if not fname.endswith('.jar'):
continue
file.save(os.path.join(config_server.mods_dir, fname))