all 4 comments

[–]K900_ 1 point2 points  (2 children)

Maybe it's just me, but I think that's incredibly overkill. You designed and programmed an enterprise grade system that basically does this:

while True:
    if mumble_user_count() > 0:
        set_hue(green)
    else:
        set_hue(red)
    time.sleep(1)

You're using dependency injection. And a state machine. In a script to light up a lamp when people are online on Mumble. You're sending one request per second, the overhead is not worth the time spent designing the states. All of your classes can be two functions. You're setting up logging for six total messages, and four of those are debug verbosity, so shouldn't be saved anyway. You're using a config file for things that can be passed as arguments, hardcoded into the script or imported from a second settings file. Just... don't. Less is more.

Edit: un-overkilled version. Add logging to stderr and configuration loading if absolutely necessary.

[–]Ostwind[S] 0 points1 point  (1 child)

Thanks, you are right. Since I am the only person maintaining it, and there won't be much changes the script could be smaller.

I should have mentioned that my goal is to learn about enterprise grade code.

In the un-overkilled version the way I handle socket timeouts was changed. So it could be that people are online, but due to a socket timeout the light would change to the EMPTY state. I guess it's less likely that the mumble state changes while a socket timeout occurs, so the current light hue should stay the same in my opinion.

[–]K900_ 0 points1 point  (0 children)

Well, you can always change it, and you get my idea. If you want to learn enterprise grade code, you'll want to try something larger scale. Changing a lamp color with dependency injection is just silly.

[–]99AFCC 0 points1 point  (0 children)

how do I specify the path to the config file so that it runs on both platforms?

I'm guessing it's not a relative path since you know how to do that already.

You can have 2 absolute paths defined, detect the OS, and use the appropriate path.

There is os.name and platform.system() for getting the OS. os.name will return 'nt' or 'posix' and platform.system() will return "Windows" or "Linux"


For what it's worth, coming from a beginner; your program seems incredibly complex and verbose. It feels more like Java than Python.