Skip to content

Commit

Permalink
Merge pull request #34 from JasonMillward/singleinstance
Browse files Browse the repository at this point in the history
Fixes #26
  • Loading branch information
JasonMillward committed Jan 31, 2014
2 parents 6ca567c + 091bb56 commit d380ddd
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 40 deletions.
4 changes: 4 additions & 0 deletions NOTES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Misc notes for future me / developers

## Single instance requires pip & tendo
sudo apt-get install python-pip
pip install tendo

## TV Shows (and maybe proper movie titles)

Disc info can be obtained, it returns a lot more information about each disc instead of just the 'is disc inserted'
Expand Down
35 changes: 17 additions & 18 deletions src/compress.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@
import ConfigParser
from handbrake import HandBrake
from timer import Timer
from tendo import singleton


me = singleton.SingleInstance()
DIR = os.path.dirname(os.path.realpath(__file__))
CONFIG_FILE = "%s/../settings.cfg" % DIR

Expand Down Expand Up @@ -60,25 +61,23 @@ def compress():
read_value('debug')
)

if not hb_api.findProcess():
if hb_api.loadMovie():
log.info( "Encoding and compressing %s" % hb_api.getMovieTitle()
stopwatch = Timer()

if hb_api.convert(args=hb_cli, nice=hb_nice, output=hb_out):
log.info( "Movie was compressed and encoded successfully")

stopwatch.stop()
log.info( ("It took %s minutes to compress %s"
%
(stopwatch.getTime(), hb_api.getMovieTitle())))
else:
stopwatch.stop()
log.info( "HandBrake did not complete successfully")
if hb_api.loadMovie():
log.info( "Encoding and compressing %s" % hb_api.getMovieTitle()
stopwatch = Timer()

if hb_api.convert(args=hb_cli, nice=hb_nice, output=hb_out):
log.info( "Movie was compressed and encoded successfully")

stopwatch.stop()
log.info( ("It took %s minutes to compress %s"
%
(stopwatch.getTime(), hb_api.getMovieTitle())))
else:
log.info( "Queue does not exist or is empty")
stopwatch.stop()
log.info( "HandBrake did not complete successfully")
else:
log.info( "Process already running skipper")
log.info( "Queue does not exist or is empty")


if __name__ == '__main__':
compress()
22 changes: 0 additions & 22 deletions src/handbrake/handbrake.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,28 +63,6 @@ def _cleanUp(self, cFile):
def _updateQueue(self, uStatus, uAdditional):
self.db.update(uid=self.ID, status=uStatus, text=uAdditional)

""" Function: findProcess
Goes through all of the running proccess and tries to find the
HandBrake proccess.
If it is running return true
Inputs:
None
Outputs:
Boolean (True/False)
"""
def findProcess(self):
processname = 'HandBrakeCLI'
for line in os.popen("ps xa"):
fields = line.split()
process = fields[4]
if process.find(processname) >= 0:
return True
break

return False

""" Function: loadMovie
Check to see if the queue file exists, if it does load the first
line and proccess it for the rest of the script to use
Expand Down
2 changes: 2 additions & 0 deletions src/rip.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
from makemkv import makeMKV
from logger import Logger
from timer import Timer
from tendo import singleton

me = singleton.SingleInstance()
DIR = os.path.dirname(os.path.realpath(__file__))
CONFIG_FILE = "%s/../settings.cfg" % DIR

Expand Down

0 comments on commit d380ddd

Please sign in to comment.