modpack-installer icon indicating copy to clipboard operation
modpack-installer copied to clipboard

I wrote a launch script for the installer.

Open pnfish opened this issue 3 years ago • 7 comments

I am new to Github, but I wanted to share my launch script for the modpack installer. It does not only manage all modpacks, but it can browse curseforge and install new ones. I wrote some comments into my code (I hope they aren't too much - I am pretty new to this whole 'share your code' thing aswell), but it is still pretty obscure (sorry for that). The script is written in python 3. It needs the magic libary: pip3 install magic-python. All other libaries sould be preinstalled. I tested the script under Linux (Ubuntu) and with various packs, but as this is a pretty long and complex code it could be that there are some unseen bugs. If there is one then I'll try to fix it. I did not edit the other scripts (of this project). I hope that I did this right with an pull request.

pnfish avatar Aug 04 '21 19:08 pnfish

I updated my script now.

  • Try/catch now only catches some exceptions (I hope I chose the right ones)

  • I replaced my Format.exchange() function

  • I redid the argument handling in my functions (instead of a string, it now hands over a dict)

  • removed the functionExecutor() (It was pretty nice for debugging, because the default exception handler doesn't output the arguments given to the function, mine did. So I could easelly reproduce the error. The one argument problem wasn't a problem, since the MenuHelper limit me to one argument anyways)

  • The install.py script is now imported and I added an automatic detection, if the installer should be run with manual-flag (although at least for me it never worked with forge, even with versions below 1.12. Every time I got an java error, if I ran it on automatic, so I disabled it. It can activated again in line 484. I can send you the error stacks/open an issue.)

I hope thats all and I didn't introduce new bugs...

pnfish avatar Aug 05 '21 16:08 pnfish

Looks much better! I'll have to check out your code and test it on my computer before I merge it.

On the topic of exception handling, you can simply catch requests.RequestError to catch all of the requests-related errors in the download function.

Also, if you're having problems with the Forge automatic installer even on v1.12.2, feel free to post your error logs in a new issue so I can get that fixed.

cdbbnnyCode avatar Aug 05 '21 17:08 cdbbnnyCode

Also, it seems like the magic library is only checking file extensions. Is it really necessary to have an entire library dependency for this, or would it be sufficient to use filename.endswith('.zip')?

cdbbnnyCode avatar Aug 05 '21 17:08 cdbbnnyCode

I think I am done now. I removed the magic lib and python 3.9 specific syntax (it should work now with every python 3 version, although I only tested it with 3.9.5). I changed the automatic manual-flag detection aswell to give more control (I did not read carfully enough and thought, that versions under 1.12.2 and not only version 1.12.2 is supported by the installer script, oopsie).

pnfish avatar Aug 05 '21 22:08 pnfish

I have merged your code into a feature branch (called launcher) so I can fix some things before I merge the code into master. I'll keep this PR open until then.

cdbbnnyCode avatar Aug 06 '21 13:08 cdbbnnyCode

I might look at this again sometime soon; it's probably very broken now with the new changes but shouldn't be too hard to rework.

cdbbnnyCode avatar Jan 28 '22 05:01 cdbbnnyCode

I wrote an updated version, but it is not fully tested since I did not have the time. But it should be functional.

pnfish avatar Jan 28 '22 06:01 pnfish

This has been open for years now, and while it works well, I don't think it really fits within the scope of the main project. If it is still used or maintained at all, I could point to it in the readme page.

cdbbnnyCode avatar Mar 26 '23 05:03 cdbbnnyCode

I forgot that this pr is still open, sorry. I currently don't have the time (and usecase) to maintain the launcher script especially since that API change a while back. I will archive my repo, therefore there is no need to link to that. If anyone wants to pick up that project feel free to do so.

pnfish avatar Mar 26 '23 06:03 pnfish