Script done problems

Discussion of Transmission that doesn't fit in the other categories
Post Reply
madrose
Posts: 4
Joined: Mon Nov 12, 2012 8:41 am

Script done problems

Post by madrose »

Hi everyone,
I have transmission 2.51 installed inside a FreeBSD jail. the client is working perfectly as user nobody and I was trying to setup a script when torrent finish downloading to process some scripts that will perform specific tasks.
My settings.json contains:

Code: Select all

    "script-torrent-done-enabled": true,
    "script-torrent-done-filename": "/work/transmission/posttorrent.sh",
My posttorrent.sh contains:

Code: Select all

#!/bin/bash
{
  start_time=`date +%s`
  # Log file, file where we tell what events have been processed.
  LOG=/work/transmission/posttorrent.log
  echo "Now searching for Subtitles" > $LOG 2>&1
  echo $start_time >> $LOG 2>&1
  echo "***************************************" >> $LOG 2>&1
  subliminal -l en PATH /work/finished >> $LOG 2>&1
  echo "***************************************" >> $LOG 2>&1
  echo "Now Sorting TV-Series" >> $LOG 2>&1
  echo "***************************************" >> $LOG 2>&1
  python /usr/local/lib/python2.7/site-packages/FlexGet-1.0-py2.7.egg/flexget/flexget_vanilla.py --logfile /work/.flexget/flexget-sorting.log -c /work/.flexget/sorting$
  echo "***************************************" >> $LOG 2>&1
  echo "Now Sorting Movie" >> $LOG 2>&1
  echo "***************************************" >> $LOG 2>&1
  python /usr/local/lib/python2.7/site-packages/FlexGet-1.0-py2.7.egg/flexget/flexget_vanilla.py --logfile /work/.flexget/flexget-sorting.log -c /work/.flexget/sorting$
  #periscope /usr/local/working -l en >> $LOG 2>&1
  echo "***************************************" >> $LOG 2>&1
  echo Finally cleanning Completed Torrents.. >> $LOG 2>&1
  echo "***************************************" >> $LOG 2>&1
  transmission-remote -l | grep 100% | grep Done | awk '{print $1}' | xargs -n 1 -I % transmission-remote -t%, -r >> $LOG 2>&1
  end_time=`date +%s`
  echo "***************************************" >> $LOG 2>&1
  echo run time is $(expr `date +%s` - $start_time) s >> $LOG 2>&1
} &
the following is a the result of the log after torrent complete downloading:

Code: Select all

Now searching for Subtitles
1352710084
***************************************
...
OSError: [Errno 2] No such file or directory: '//.config/subliminal'
...
***************************************
Now Sorting TV-Series
***************************************
***************************************
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/FlexGet-1.0-py2.7.egg/flexget/flexget_vanilla.py", line 8, in <module>
    import flexget
  File "/usr/local/lib/python2.7/site-packages/FlexGet-1.0-py2.7.egg/flexget/__init__.py", line 9, in <module>
    from flexget.manager import Manager
  File "/usr/local/lib/python2.7/site-packages/FlexGet-1.0-py2.7.egg/flexget/manager.py", line 8, in <module>
    import sqlalchemy
  File "build/bdist.freebsd-8.3-RELEASE-p4-amd64/egg/sqlalchemy/__init__.py", line 52, in <module>

  File "build/bdist.freebsd-8.3-RELEASE-p4-amd64/egg/sqlalchemy/types.py", line 33, in <module>
    except NameError:
  File "build/bdist.freebsd-8.3-RELEASE-p4-amd64/egg/sqlalchemy/processors.py", line 98, in <module>
  File "build/bdist.freebsd-8.3-RELEASE-p4-amd64/egg/sqlalchemy/cprocessors.py", line 7, in <module>
  File "build/bdist.freebsd-8.3-RELEASE-p4-amd64/egg/sqlalchemy/cprocessors.py", line 4, in __bootstrap__
  File "/usr/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 882, in resource_filename
  File "/usr/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 1351, in get_resource_filename
  File "/usr/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 1373, in _extract_resource
  File "/usr/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 962, in get_cache_path
  File "/usr/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/pkg_resources.py", line 928, in extraction_error
pkg_resources.ExtractionError: Can't extract file(s) to egg cache

The following error occurred while trying to extract file(s) to the Python egg
cache:

  [Errno 13] Permission denied: '//.python-eggs'

The Python egg cache directory is currently set to:

  //.python-eggs

Perhaps your account does not have write access to this directory?  You can
change the cache directory by setting the PYTHON_EGG_CACHE environment
variable to point to an accessible directory.

***************************************
Now Sorting Movie
***************************************
....
...
pkg_resources.ExtractionError: Can't extract file(s) to egg cache

The following error occurred while trying to extract file(s) to the Python egg
cache:

  [Errno 13] Permission denied: '//.python-eggs'

The Python egg cache directory is currently set to:

  //.python-eggs

Perhaps your account does not have write access to this directory?  You can
change the cache directory by setting the PYTHON_EGG_CACHE environment
variable to point to an accessible directory.

***************************************
Finally cleanning Completed Torrents..
***************************************
localhost:9091/transmission/rpc/ responded: "success"
***************************************
run time is 3 s

as you can see from the log, the script runs some elements and clean the completed torrent successfully, however other parts of the script fail to run due to permission issue. If I run the script from the command line it runs perfectly with no error.

any idea how to solve this?

I tried to run transmission as root and transmission user, however there was other type of errors as well.


appreciate the help.
radir
Posts: 18
Joined: Sat Apr 18, 2009 4:47 pm

Re: Script done problems

Post by radir »

hi,

Have you installed flexget with all necessary dependencies in jail? Can be wrong but it seems to me: flexget is not installed yet and running flexget would first install it BUT you are running transmission as user nobody hence install will fail obviously. Nobody user dont have permission to install to /usr/local/lib. Also make sure user running flexget have the permission to write to the logfile as it is neither tolerated by python/flexget.

By the way if you use flexget with transmission install transmissionrpc module as well. And always test flexget config file (--check, --test) otherwise you'll be surprised why FL dont work as expected. Learned the hard way ;-)

Regards
madrose
Posts: 4
Joined: Mon Nov 12, 2012 8:41 am

Re: Script done problems

Post by madrose »

Hi radir,
I have flexget installed and running perfectly with transmission, no issue with that. even the subliminal script for subtitle download is working perfectly on its own.

the problem only when I put those in the script that run when torrent finish.

I am using flexget with
atlanta800
https://github.com/atlanta800/dotfiles/ ... er/flexget and it works perfect to download movies and TV-Series. thanks for the advise.

I tried also running transmission as root/transmission and other issues come up as user transmission could not run anything, and user root was failing when trying to remove the done torrent from transmission. all my scripts are installed as root.
madrose
Posts: 4
Joined: Mon Nov 12, 2012 8:41 am

Re: Script done problems

Post by madrose »

I just tried running transmission as root, and chown all files to root as well.

when the script is run I get:
/work/transmission/posttorrent.sh: line 13: python: command not found
madrose
Posts: 4
Joined: Mon Nov 12, 2012 8:41 am

Re: Script done problems

Post by madrose »

Ok. I am answering my own question.

After so much trial and error, it turned out that the problem was in the PATH, so I added:

Code: Select all

PATH=$PATH:/usr/local/bin
export PATH
and it worked.
Post Reply