LinuxGSM icon indicating copy to clipboard operation
LinuxGSM copied to clipboard

[LGSM] Considuring a move to Python

Open dgibbs64 opened this issue 10 years ago • 51 comments

I am currently considering moving LGSM to Python rather than BASH. LGSM has grown very large and I believe that it may be time to move to a more capable language. I believe Python may be the right way forward.

Development is becoming quite slow for LGSM as it takes quite a while to test everything and am finding limits to BASH. I believe it would be easier to develop and improve existing features using a 'full' language rather that a scripting language like BASH.

Idealy if I was to do this I would like to transition over time slowly replacing functions. until a full move has been made.

The main issue for me is that I will have to learn a new language which will take time. However i believe in the long term will be of benefit.

I also believe it may become easier for developers to contribute code to LGSM as Python is a very well known and popular language.

Your thoughts and ideas are welcome.

dgibbs64 avatar Dec 12 '15 19:12 dgibbs64

That would be really awesome.

Your project needs a better language to grow. But please, do it in Python 3 =).

By the way, you could apply for an open source license of Pycharm. Your project have all the requirements.

ghost avatar Dec 14 '15 11:12 ghost

As long as the script is just as easy to use, not many people would care.

The ease-of-us of your current script is why it's so popular.

If you keep that level of simplicity, then the move will be easy.

You could always just start it on another branch anyway, and just accept any contributions through here on Github.

But yes, I have seen how powerful Python is, and the move would definitely provide more benefits. Only 1 downside would be the time it would take.

I can test anything that you may have

ScottSmudger avatar Dec 14 '15 11:12 ScottSmudger

Ease of use it my number one priority. I don't want to over complicate the scripts. And python 3 makes sense to use :-)

dgibbs64 avatar Dec 14 '15 20:12 dgibbs64

I am totally for this idea, but just 2 things to keep in mind:

  1. Please, for the love of all things holy, go with Python 3 rather than 2. (if you do this)
  2. Don't forget that you can port parts of the project without porting all of it. For example, it wouldn't hurt to write the functions in Python but possibly leave the individual server scripts as bash. Not necessarily suggesting this (I support an entire overhaul to Python) just something to keep in mind.

Zer0t3ch avatar Dec 14 '15 23:12 Zer0t3ch

Anyone recommend good tutorials/resources and tools that can help me learn python? I have installed PyCharm but I need a decent tutorial to get started and get a development environment running.

dgibbs64 avatar Dec 16 '15 16:12 dgibbs64

Hi,

I strongly recomend this course: https://www.udemy.com/pythonforbeginnersintro/

For reference, i sometimes go to https://pymotw.com/2/ to pick some examples.

If you need anything regarding python, send me a message and i will be glad to help on the migration process.

ghost avatar Dec 16 '15 17:12 ghost

Thanks for this. Once I get going I should be OK. Then I could ask you more specific questions. Currently I need all the basics so I can at least know what im looking at haha. :D

dgibbs64 avatar Dec 16 '15 17:12 dgibbs64

No problem :)

One must allways help those who want to learn python.

Also,

print this, and stick it behind your monitor:

http://blog.jetbrains.com/pycharm/files/2010/07/PyCharm_Reference_Card.pdf

http://fossbytes.com/learn-it-faster-the-entire-python-language-in-a-single-image/

ghost avatar Dec 16 '15 17:12 ghost

@dgibbs64 I highly suggest https://www.codecademy.com/ as well. It's less thorough than other materials, but it's great to pop in and out of as references or reminders are needed. I used to do Python all the time, but stopped for a while, and now I visit that site from time-to-time when I need quick refreshers on syntax and whatnot.

Zer0t3ch avatar Dec 16 '15 23:12 Zer0t3ch

Also, if you do end up doing this Python merge, we could even add an optional GUI in Tk or something similar, on top of the fact that the entire project would become significantly more cross-platform.

On a sidenote, I'm currently thinking of forking and adding another game server, would you be open to merging it once it's done if I somehow manage to do it in Python? (It would be a bit of a bitch to load/call the bash functions you've made, but I could make it work, and it would be a good first step for porting the project over)

Zer0t3ch avatar Dec 16 '15 23:12 Zer0t3ch

I'm a (much) bigger fan of bash than python - use both, curse at only one - so this is a bit of a letdown. Bash scripting was the reason why I initially adopted the lgsm scripts.

The bash root shell is the only hash I've ever smoked.

lnxprof avatar Dec 17 '15 18:12 lnxprof

@lnxprof Is there anything that bash provides over Python, though? I mean, when it was just a little project, bash made sense. Servers could be quickly and easily thrown together, and it could run on most any machine, bash was practical. But, as the project grows with more and more servers, and even possibly more features, does it not make sense to move to something a bit more "extensible"?

Zer0t3ch avatar Dec 17 '15 23:12 Zer0t3ch

@Zer0t3ch Absolutely. Let's start with just this one: 90 MB of additional cruft in overhead to deploy python3 - additional add-on libs notwithstanding. 0MB of additional cruft to deploy bash+sed+awk+curl For disk-limited VPS servers, that's a big hit.

lnxprof avatar Dec 18 '15 01:12 lnxprof

@lnxprof Fear not!

If you need any help on setting up we can help :)

ghost avatar Dec 18 '15 17:12 ghost

One idea,

lgsm could be totally revamped by using Flask.

An idea, would be implementing an Admin panel for manage the server , or download servers:

example: https://wrapbootstrap.com/theme/inspinia-responsive-admin-theme-WB0R5L90S

ghost avatar Dec 18 '15 17:12 ghost

@pereirtc an admin panel is something that is regularly requested however if a web panel was designed I would like it as a optional add-on feature as many users are happy with the simple CLI. My focus will remain as a CLI application (even though I would love a web interface). Once I get the CLI right move on to a web based add-on.

My number 1 focus will always simplicity for the user. Any more complicated features have to be carefully thought about to ensure that its easy for the end user to do. This is why multiple server instance support has been an issue as its not that easy to do simply.

Both @Zer0t3ch and @lnxprof have valid points. My issue currently is that because LGSM has grown to a large project from a few basic scripts, managing and developing has become slower and more cumbersome. I believe that's because BASH scripts are not really designed to be used as a full application as LGSM has become.

I believe the python overhead would be worth the improvements. I should be able to create and the improved speed of development and testing. Should also make my life easier (when I learn it) when developing LGSM.

dgibbs64 avatar Dec 18 '15 17:12 dgibbs64

@dgibbs64 You are right, going to an admin panel would be out of the scope of the project.

Regarding python itself, i'm going to post here some directions about modules wich you should check it out, i believe it will be a direct help for what you seek:

Argument parsing: https://pymotw.com/2/argparse/index.html#module-argparse Configuration parsing: https://pymotw.com/2/ConfigParser/index.html#module-ConfigParser Executing OS commands: https://pymotw.com/2/subprocess/index.html#module-subprocess Http request: http://docs.python-requests.org/en/latest/ Colors :) : https://pypi.python.org/pypi/colorama

Git Integration ( maybe to checkout latest rev of your utility scrips?) : https://github.com/gitpython-developers/GitPython

With that, you can have the base for parsing arguments, use a .ini file to store configurations and most import.

Colors, beautifull colors hehe

ghost avatar Dec 18 '15 18:12 ghost

thanks @pereirtc thats amaze balls :D. Been watching the tutorial you sent. Very useful so far

dgibbs64 avatar Dec 18 '15 18:12 dgibbs64

I'm going to play the curmudgeonly old developer here and throw some rain on the parade, but only because I think we may want to consider what we're doing. This is all my opinion based upon being a fairly successful devops guy with some solid success in designing and bringing some pretty big products to market successfully, and my perspective as a user and big fan of this project.

A major no-go red flag for me is Daniel's relative beginner status with Python, seeing as he is the primary developer here, the best time to learn a language isn't during a refactor of an already widely deployed product. At a minimum, I'd start a fresh fork of this and try it out with the mindset that it might not work and be ready to fold it up, but then we run into issues where we're fixing issues in two code bases. Trying to keep a fork in sync in that manner quickly becomes its own undertaking, and might really degrade the ability to keep progress going here.

As a slowly-getting-better Python programmer, I agree that there are features in the language that can make an improvement in development. In particular, there are some ways Python can handle data and functional structures that Bash simply cannot compete with. The question is, do those improvements result in a benefit for the end user, either by way of increased capability or simply a better maintained and more frequently updated product? UX should drive all decisions, if a feature has benefit only for the developers and can't be expressed in terms of a better user experience, it's usually better to skip that work and focus on what the user needs. Even in open source, customer focus should be at the top of the list.

However, my opinion is that the tooling should always follow the needs of design, not the other way around. We define a roadmap, determine needs and requirements, and select a tool for each phase based upon those needs mixed with our own expertise levels. To turn the issue on its head, you say that the testing and ability to solicit contributions is behind the change. So, rather than look simply at Python, let us consider each of those points in a vacuum, and see what the better option is.

In regards to testing, my experience in helping build development teams over the past 10 years is that testing is testing, and it is all about mindset and desire to build correctly rather than quickly. There are tools to help make testing easier, there are tools to help catch you when you don't build proper code, and there are tools to help QA find out problems before release, but they all require a lot of smarts to implement and still require a testing mindset. For smaller projects like this, a lot of times the developers themselves write the tests, which may result in testing that either doesn't match real-world usage, or simply tests the parts of the code the developer already considers important. Point being, when one writes one's own tests, it usually tests the "best" of the work in the first place, seeing as it is the focus of the developer's attention.

So, my suggestion here is rather than look at a new language, we look at how we test the product. I'd start by reviewing the bugs and issues reported, try to solicit data from end users about what games and platforms they are using, and focus testing on making sure those use cases are the focus of the testing drive. We need to look at testing as a way to ensure the majority of users have no issues, rather than simply trying to nail down every technical defect in the product. Focusing in this way helps foster the attitude that we are working to improve the user's experience with the product, rather than looking at what we ourselves think of as important. I've made this mistake myself many times (and still do to this day), but the more we can look outside and get feedback from users, the easier this becomes.

From there, I'd focus on deciding how we want to actually test. Do we want to build a "testers group" of users who have used the product to help test and validate issues, or do we want to build out an entire testing platform ourselves? That helps us decide the next step, of how we actually want to unit test. Will we use an external tool to perform functional tests, or do we simply create scripts to use the product and then validate the output? From there we get into the most difficult part, namely what combinations of tests we will run, and how to determine when a change in the code should trigger one of the test paths? Testing is never "ready" in the sense that it can never test every single combination, but keeping this sort of progression in mind can help figure out where we want to focus first.

My guess here is that given the relatively small developer team, and the use of the product, a good starting point is better instrumentation of the code and better ability for users to report back. If I were in charge, I'd start adding more information about what the script is doing and put that into a simple log so that users can more accurately determine what is happening, and so that their bug reports contain better information. The key is to make is as absolutely simple as possible for a user to take an issue and get it to us with the most actionable information, so thinking in that manner should give us a good idea of what we'd have to add to make this work.

I'd also focus on a core test case of simply creating a new environment and running through create/use/teardown scenarios of each product on each OS platform as a good first step towards a better test methodology. Testing is unfortunately a discipline which has diminishing returns the more time one invests in it, so we may find 90% of the bugs with this simple setup, and then have to spend orders of magnitude more time nailing down the last 10%. It may never be developer time to user failure efficient, so there will always be tests that simply aren't worth the effort to implement. But my guess is this could be done with about a week and a key for each game, using Vagrant on our own machines, and then we could collaborate on the testing toolchain and build something decent.

All of that said, even if Python does end up being the better option, we then need to factor in all the dependencies and issues attendant with such a move. Users now will need to have Python installed and whatever libraries we need, which increases the stuff users have to do before they run the product. In my experience, the more complex the setup the less likely a user will try the product, so I really don't want to give up the existing simplicity we have. In fact, I'd argue that if we want to improve the product more, we'd look at integrating the prerequisite installation and checks into the tool, so that users would simply need to download and go, as the script finds and fixes dependency issues as a part of pre-flight.

I guess all that text can be TL;DR as "Be careful, make decisions based on the roadmap instead of what is fun". It's boring, but unfortunately success is usually pretty boring.

jaredballou avatar Dec 26 '15 23:12 jaredballou

@jaredballou Agreed, maybe it's best to keep the Python port in a separate branch. Continue development for the current bash scripts until @dgibbs64 has the required Python experience for a full conversion or if another experience Python developer helps out. I don't believe it's worth replacing what currently works. A select amount of people will be able to help you out with testing your python ports, me included.

ScottSmudger avatar Dec 27 '15 07:12 ScottSmudger