def setMediaPath(directory): """Method to set the media path by setting the directory to use Parameters: directory - the directory to use for the media path """ Config.setConfigVal("CONFIG_MEDIA_PATH", directory)
def __runScript(self, script, *argv): """Run a Python script in a subprocess Parameters ---------- script : str the script to run; must be in the jes4py directory *argv : list parameters to pass to script on command line Returns ------- Popen instance """ # Start subprocess using current Python intepreter to run a script scriptpath = os.path.join(Config.getConfigVal("CONFIG_JES4PY_PATH"), script) proc = subprocess.Popen([sys.executable, scriptpath] + list(argv), stdin=PIPE) # Register atexit handler if this is the first subprocess if len(self.subprocessList) == 0: atexit.register(self.__stopAllSubprocesses) # Record the process and return self.subprocessList.append(proc) return proc
def getMediaDirectory(): """Method to get the directory for the media Returns: the media directory """ return Config.getConfigVal("CONFIG_MEDIA_PATH")
def getMediaPath(fileName): """Method to get full path for the passed file name Parameters: fileName - the name of a file Returns: the full path for the file """ return os.path.join(Config.getConfigVal("CONFIG_MEDIA_PATH"), fileName)
def pickADirectory(): """Method to let the user pick a directory and return the full path as a string. Returns: the full directory path """ # Create open file dialog directory = Config.getConfigVal('CONFIG_SESSION_PATH') scriptpath = os.path.join(Config.getConfigVal("CONFIG_JES4PY_PATH"), 'filePicker.py') path = subprocess.check_output( [sys.executable, scriptpath, 'folder', directory]).decode() if path == '': return None else: Config.setConfigVal('CONFIG_SESSION_PATH', path) return path
def pickAColor(cls): # Start subprocess using current Python intepreter to run a script scriptpath = os.path.join(Config.getConfigVal("CONFIG_JES4PY_PATH"), 'colorPicker.py') color = subprocess.check_output([sys.executable, scriptpath]).decode() if color == '': color = None else: color = Color(list(map(int, color.split()))) return color
def pickAFile(): """Method to let the user pick a file and return the full name as as a string. If the user didn't pick a file then the name will be None. Returns: the file file name of the picked file or None """ # Create open file dialog directory = Config.getConfigVal('CONFIG_SESSION_PATH') scriptpath = os.path.join(Config.getConfigVal("CONFIG_JES4PY_PATH"), 'filePicker.py') path = subprocess.check_output( [sys.executable, scriptpath, 'file', directory]).decode() if path == '': return None else: Config.setConfigVal('CONFIG_SESSION_PATH', os.path.dirname(path)) return path
def __init__(self, sound, frameNumber): """Constructor Parameters ---------- sound : Sound sound the frame (sample) belongs to frameNumber : int index of frame (sample) """ self.wrapLevels = Config.getConfigVal("CONFIG_WRAPPIXELVALUES") self.sound = sound self.frameNumber = frameNumber
def __init__(self, image=None, x=None, y=None): """Pixel constructor Parameters ---------- image : PIL.Image image the pixel belongs to x : int column of the pixel y : int row of the pixel """ self.wrapLevels = Config.getConfigVal("CONFIG_WRAPPIXELVALUES") self.image = image self.x = x self.y = y
from jes4py import Config # Add other "top-level" modules here from jes4py.media import * #from jes4py.sound import * Config.initDict() Config.initPath()
def pickMediaPath(): path = pickADirectory() Config.setConfigVal("CONFIG_MEDIA_PATH", path)