Re: J. River Media Center Command Sender
Posted: Fri Aug 10, 2018 1:08 am
I get the j. river media center is not installed message with the above. Here is a capture of how I made the change
Code: Select all
except WindowsError:
pass
Code: Select all
except WindowsError:
raise
Code: Select all
Traceback (most recent call last) (0.5.0-rc4):
File "C:\Program Files (x86)\EventGhost\eg\Classes\PluginInstanceInfo.py", line 102, in CreateInstance
plugin.__init__()
File "C:\ProgramData\EventGhost\plugins\JRiverCommands\__init__.py", line 3202, in __init__
key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, reg_path)
WindowsError: [Error 2] The system cannot find the file specifiedSorry, I should have been more specific. I have the 64 bit version of JRMC 25 installed. Thanks.topix wrote: Sun Feb 10, 2019 10:39 pm I think you have a 64Bit installation of J.River Media Center. I've made small changes to access the registry on 64Bit. Please test the attached version.
Code: Select all
def _get_reg_value(path, key):
d = _read_reg_values(path)
if key in d:
return d[key]
return ''
def _read_reg_keys(key):
if isinstance(key, tuple):
root = key[0]
key = key[1]
else:
root = _winreg.HKEY_LOCAL_MACHINE
key = 'SOFTWARE\\Wow6432Node' + key
try:
handle = _winreg.OpenKeyEx(root, key)
except _winreg.error:
return []
res = []
for i in range(_winreg.QueryInfoKey(handle)[0]):
res += [_winreg.EnumKey(handle, i)]
return res
def _read_reg_values(key):
if isinstance(key, tuple):
root = key[0]
key = key[1]
else:
root = _winreg.HKEY_LOCAL_MACHINE
key = 'SOFTWARE\\Wow6432Node' + key
try:
handle = _winreg.OpenKeyEx(root, key)
except _winreg.error:
return {}
res = {}
for i in range(_winreg.QueryInfoKey(handle)[1]):
name, value, _ = _winreg.EnumValue(handle, i)
res[_convert_mbcs(name)] = _convert_mbcs(value)
return res
def _convert_mbcs(s):
dec = getattr(s, "decode", None)
if dec is not None:
try:
s = dec("mbcs")
except UnicodeError:
pass
return s
class JRiverCommand(eg.PluginBase):
def __init__(self):
high_version = (0, 0, 0)
self.jriver_exe = None
self.jriver_cwd = None
reg_path = r'J. River\\Media Core\\Installations\\Media Center 25'
for reg_key in _read_reg_keys(reg_path):
version = _get_reg_value(reg_path + '\\' + reg_key, 'Version')
if version:
version = tuple(int(v) for v in version.split('.'))
if (
version[0] > high_version[0] or
(
version[0] == high_version[0] and
version[1] > high_version[1]
) or
(
version[0] == high_version[0] and
version[1] == high_version[1] and
version[2] > high_version[2]
)
):
self.jriver_exe = _get_reg_value(
reg_path + '\\' + reg_key,
'Launcher Name'
)
self.jriver_cwd = _get_reg_value(
reg_path + '\\' + reg_key,
'Path'
)
high_version = version
if self.jriver_exe is None:
eg.PrintError('J. River Media Center is not installed.')
action_list = ()
for command_description in sorted(COMMANDS.keys()):
command_data = COMMANDS[command_description]
code = command_data['code']
value = command_data['value']
class_name = 'fn' + command_description.replace(' ', '_').upper()
action_list += ((
SendCommand,
class_name,
command_description,
command_description,
[code, value]
),)
self.AddActionsFromList(action_list)
def __stop__(self):
pass
def __start__(self):
pass