Have a look at my absolute series scanner packaged with my HAMA agent...
. Agents follows the framework but can still write and read into the agent data folder, but cannot create folders by themselves
. Scanners are not part of the framework, and from my findings it needs to use absolute path which are OS specific
I did use a log function from within the scanner for development and T/S reasons, which was only done in one another scanner with a file.write function.
I did write this function, and tried to make it generic across os but failed. I use sinology and it puts the logs into "homes/plex" folder by default. If folder rights are amended should works on most OS. Any feedback on that would be nice
### Log function ########################################################################################
def Log(entry, filename='Plex Media Scanner Custom.log'): #need relative path
#Logging = [ ['Synology', "/volume1/Plex/Library/Application Support/Plex Media Server/Logs/"],
# ['Synology2', "../../Plex/Library/Application Support/Plex Media Server/Logs/"],
# ['Ubuntu-10.04', "/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Logs/"],
# ['windows Vista/7/8', "C:\\Users\\Default\\AppData\\Local\\Plex Media Server\\Logs\\"],
# ['Qnap', ""] ]
try:
with open(filename, 'a') as file: #time now.strftime("%Y-%m-%d %H:%M") + " " + datetime.datetime.now() + " " + #doesn't work for timestamps
#for line in file:
# if entry in line: break
#else: ###gets there if "for" wasn't "break", used for unique lines in logging file
file.write( entry + "
" ) #
make it readable in notepad under windows directly print line + "
" #for command line execution, output to terminal except: pass
And main function:
### Look for episodes ###################################################################################
def Scan(path, files, mediaList, subdirs, language=None, root=None):
Root scan for OS information that i need to complete the Log function
if path == “”:
Log("================================================================================")
try:
os_uname=""
for string in os.uname(): os_uname += string
Log(“os.uname(): ‘%s’” % os_uname) #(sysname, nodename, release, version, machine) #
Log(“Sys.platform: ‘%s’” % sys.platform) #
Log(“os.name: ‘%s’” % os.name) # ‘posix’, ‘nt’, ‘os2’, ‘ce’, ‘java’, ‘riscos’.)
Log(“os.getcwd: ‘%s’” % os.getcwd()) # Current dir: /volume1/homes/plex
Log(“root folder: ‘%s’” % root if root is not None else “”)
except: pass
This output doesn't work in all Operating Systems so i had trouble writing a generic enough function...
Please let me know of any advance in functionality as i want to have logging working across all OS, and the above should give you a head start