So my program is progressing quite nicely, and I'm semi-proud of myself for getting this far (I'm a newbie), but I had 2 questions. One question is that my program recognizes a .CFG extension...but never finds games with any other extension (.smc, .srm). I type it in EXACTLY as it is in the folder its in, and im sure that the function isnt written wrong because it returns True for the only game I had as a CFG format. Any ideas?
Also, how would one import photos and files and things to use in a python program (such as pictures for backgrounds, jpegs to be used inside the program, etc)?
Thanks! :)
import os, time, subprocess, shlex, logging, platform
from tkinter import *
try:
import Tkinter as tk
from urllib2 import urlopen
except ImportError:
import tkinter as tk
from urllib.request import urlopen
def debug():
if platform.platform().startswith('Windows'):
logging_file = os.path.join(os.getenv('HOMEDRIVE'), os.getenv('HOMEPATH'), 'konsole_kollection.log')
else:
logging_file = os.path.join(os.getenv('HOME'), 'konsole_kollection.log')
print('Logging To: ', logging_file)
logging.basicConfig(
level=logging.DEBUG,
format ='%(asctime)s : %(levelname)s : %(message)s',
filename = logging_file,
filemode = 'w',
)
logging.debug("Start")
logging.info("Running")
logging.warning("Warnings")
logging.critical("P0 Errors")
logging.error("P1 Errors")
def videoGame():
'''This function opens up the Snes9x player in the Applications folder.'''
print(videoGame.__doc__)
# export PYTHONPATH=/Users/xxxx/Desktop/Python3:$PYTHONPATH
logging.debug('Initializing SNES Locator')
extensions =('.src', '.srm', '.CFG')
subprocess.call(['ls', '/SNES/SNESRoms'])
while True:
command_line = input('Enter the game you would like to search for: ')
for data in os.listdir('/SNES/SNESRoms'):
if command_line.endswith(extensions):
arguments = shlex.split(command_line)
print(arguments)
master_process = subprocess.Popen(["open /Applications/Snes9x.app", command_line], shell=True,
executable=None, stdin=None, stdout=None, stderr=None, preexec_fn=None, close_fds=False,
cwd=None, env=None, universal_newlines=False, startupinfo=None, creationflags=0)
logging.info('Running SNES Locator')
return False
else:
print('Invalid input error, please enter a valid game format.')
logging.error('Error Code 1: Invalid Input Error')
break
else:
print(command_line)