Skip to content

Commit

Permalink
Attempt to address #55
Browse files Browse the repository at this point in the history
  • Loading branch information
Weston Nielson committed Mar 23, 2017
1 parent cb5c41e commit 9ca8731
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
22 changes: 15 additions & 7 deletions prt.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,7 @@
except:
from xml.etree import ElementTree as ET

try:
import psutil
except:
psutil = None
import psutil

try:
from termcolor import colored
Expand Down Expand Up @@ -101,8 +98,7 @@ def colored(msg, *args):
SSH_HOST_RE = re.compile(r'ssh +([^@]+)@([^ ]+)')

__author__ = "Weston Nielson <wnielson@github>"
__version__ = "0.4.2"

__version__ = "0.4.3"

def get_config():
path = os.path.expanduser("~/.prt.conf")
Expand Down Expand Up @@ -306,6 +302,17 @@ def transcode_local():
def transcode_remote():
setup_logging()

log.info("Checking for orphaned PRT processes")
for proc in psutil.process_iter():
try:
if proc.name == "ssh" and 'PLEX_MEDIA_SERVER' in ' '.join(proc.cmdline):
if proc.parent.pid == 1:
log.info('Found orphaned PRT process (pid %s)...killing' % proc.pid)
proc.terminate()
proc.wait()
except psutil.NoSuchProcess:
pass

config = get_config()
args = sys.argv[1:]

Expand Down Expand Up @@ -394,7 +401,8 @@ def transcode_remote():
# TODO: Remap file-path to PMS URLs
#

args = ["ssh", "%s@%s" % (host["user"], hostname), "-p", host["port"]] + [command]
args = ["ssh", "-tt", "%s@%s" % (host["user"], hostname), "-p", host["port"]] + [command]


log.info("Launching transcode_remote with args %s\n" % args)

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@ def get_version():
'prt_remote=prt:transcode_remote'
],
},
install_requires=['termcolor']
install_requires=['termcolor', 'psutil']
)

0 comments on commit 9ca8731

Please sign in to comment.