Created
July 6, 2017 09:11
-
-
Save Ryochan7/a62de36da6f40654ec7542231130b876 to your computer and use it in GitHub Desktop.
Python module that makes using DCNow a little easier
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import os | |
import sys | |
import time | |
import signal | |
import logging | |
# cd to directory containing upstream DreamPi source code | |
os.chdir("/home/ryochan7/Sources/dreampi/") | |
import config_server | |
import dreampi | |
import dcnow | |
logging.getLogger("dcnow").setLevel(logging.INFO) | |
logging.getLogger("dcnow").addHandler(logging.StreamHandler()) | |
active = False | |
def signal_handler(signal, frame): | |
global active | |
#print("You pressed Ctrl+C!") | |
print("\nAttempting to quit program.") | |
#sys.exit(0) | |
active = False | |
signal.signal(signal.SIGINT, signal_handler) | |
print("Starting config server") | |
config_server.start() | |
print("Go online with Dreamcast Now!") | |
dchelp = dcnow.DreamcastNowService() | |
dchelp.go_online("192.168.1.151") | |
active = True | |
print("Starting main loop") | |
while active: | |
#try: | |
time.sleep(0.1) | |
#except KeyboardInterrupt as e: | |
# pass | |
#except KeyboardInterrupt as e: | |
# print("\nException caught") | |
# active = False | |
print("Going offline") | |
dchelp.go_offline() | |
print("Finished") | |
config_server.stop() | |
#sys.exit(0) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment