Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
SiCKRAGE
sickrage
Commits
eca1d42f
Commit
eca1d42f
authored
Nov 11, 2018
by
echel0n
Browse files
Refactored naming convention of misc helper functions.
Added ability to disable stripping of special permissions from files.
parent
63f98ef0
Changes
17
Hide whitespace changes
Inline
Side-by-side
changelog.md
View file @
eca1d42f
# Changelog
-
*
fec82ca - 2018-11-11: Cleaned up subtitles code.
-
*
23957a3 - 2018-11-11: Refactored naming convention of misc helper functions. Added ability to disable stripping of special permissions from files.
-
*
63f98ef - 2018-11-11: Cleaned up subtitles code.
-
*
1558dce - 2018-11-10: Fixed issue with displaying language flags in views
-
*
0173a0f - 2018-11-10: Release v9.4.28
-
*
c5ea143 - 2018-11-10: Release v9.4.27
...
...
sickrage/core/__init__.py
View file @
eca1d42f
...
...
@@ -204,14 +204,14 @@ class Core(object):
# migrate old database file names to new ones
if
os
.
path
.
isfile
(
os
.
path
.
abspath
(
os
.
path
.
join
(
self
.
data_dir
,
'sickbeard.db'
))):
if
os
.
path
.
isfile
(
os
.
path
.
join
(
self
.
data_dir
,
'sickrage.db'
)):
helpers
.
move
F
ile
(
os
.
path
.
join
(
self
.
data_dir
,
'sickrage.db'
),
os
.
path
.
join
(
self
.
data_dir
,
'{}.bak-{}'
helpers
.
move
_f
ile
(
os
.
path
.
join
(
self
.
data_dir
,
'sickrage.db'
),
os
.
path
.
join
(
self
.
data_dir
,
'{}.bak-{}'
.
format
(
'sickrage.db'
,
datetime
.
datetime
.
now
().
strftime
(
'%Y%m%d_%H%M%S'
))))
helpers
.
move
F
ile
(
os
.
path
.
abspath
(
os
.
path
.
join
(
self
.
data_dir
,
'sickbeard.db'
)),
os
.
path
.
abspath
(
os
.
path
.
join
(
self
.
data_dir
,
'sickrage.db'
)))
helpers
.
move
_f
ile
(
os
.
path
.
abspath
(
os
.
path
.
join
(
self
.
data_dir
,
'sickbeard.db'
)),
os
.
path
.
abspath
(
os
.
path
.
join
(
self
.
data_dir
,
'sickrage.db'
)))
# load config
self
.
config
.
load
()
...
...
sickrage/core/caches/image_cache.py
View file @
eca1d42f
...
...
@@ -28,7 +28,7 @@ from hachoir_metadata import extractMetadata
from
hachoir_parser
import
guessParser
import
sickrage
from
sickrage.core.helpers
import
copy
F
ile
from
sickrage.core.helpers
import
copy
_f
ile
from
sickrage.metadata
import
GenericMetadata
...
...
@@ -226,7 +226,7 @@ class ImageCache(object):
os
.
makedirs
(
self
.
_thumbnails_dir
())
sickrage
.
app
.
log
.
info
(
"Copying from "
+
image_path
+
" to "
+
dest_path
)
copy
F
ile
(
image_path
,
dest_path
)
copy
_f
ile
(
image_path
,
dest_path
)
return
True
...
...
sickrage/core/config.py
View file @
eca1d42f
...
...
@@ -433,6 +433,7 @@ class Config(object):
self
.
calendar_icons
=
False
self
.
no_restart
=
False
self
.
allowed_video_file_exts
=
[]
self
.
strip_special_file_bits
=
False
self
.
thetvdb_apitoken
=
""
self
.
trakt_api_key
=
'5c65f55e11d48c35385d9e8670615763a605fad28374c8ae553a7b7a50651ddd'
self
.
trakt_api_secret
=
'b53e32045ac122a445ef163e6d859403301ffe9b17fb8321d428531b69022a82'
...
...
@@ -830,7 +831,8 @@ class Config(object):
'keep_processed_dir'
:
True
,
'processor_follow_symlinks'
:
False
,
'allowed_extensions'
:
'srt,nfo,srr,sfv'
,
'view_changelog'
:
False
'view_changelog'
:
False
,
'strip_special_file_bits'
:
True
},
'NZBget'
:
{
'nzbget_host'
:
''
,
...
...
@@ -1517,6 +1519,7 @@ class Config(object):
self
.
random_user_agent
=
self
.
check_setting_bool
(
'General'
,
'random_user_agent'
)
self
.
allowed_extensions
=
self
.
check_setting_str
(
'General'
,
'allowed_extensions'
)
self
.
view_changelog
=
self
.
check_setting_bool
(
'General'
,
'view_changelog'
)
self
.
strip_special_file_bits
=
self
.
check_setting_bool
(
'General'
,
'strip_special_file_bits'
)
# GUI SETTINGS
self
.
gui_lang
=
self
.
check_setting_str
(
'GUI'
,
'gui_lang'
)
...
...
@@ -2018,7 +2021,8 @@ class Config(object):
'processor_follow_symlinks'
:
int
(
self
.
processor_follow_symlinks
),
'delete_non_associated_files'
:
int
(
self
.
delete_non_associated_files
),
'allowed_extensions'
:
self
.
allowed_extensions
,
'view_changelog'
:
int
(
self
.
view_changelog
)
'view_changelog'
:
int
(
self
.
view_changelog
),
'strip_special_file_bits'
:
int
(
self
.
strip_special_file_bits
)
},
'GUI'
:
{
'gui_lang'
:
self
.
gui_lang
,
...
...
sickrage/core/helpers/__init__.py
View file @
eca1d42f
...
...
@@ -21,6 +21,7 @@ from __future__ import unicode_literals
import
base64
import
ctypes
import
datetime
import
errno
import
io
import
os
import
platform
...
...
@@ -435,39 +436,42 @@ def list_media_files(path):
return
files
def
copy
F
ile
(
src
F
ile
,
dest
F
ile
):
def
copy
_f
ile
(
src
_f
ile
,
dest
_f
ile
):
"""
Copy a file from source to destination
:param src
F
ile: Path of source file
:param dest
F
ile: Path of destination file
:param src
_f
ile: Path of source file
:param dest
_f
ile: Path of destination file
"""
try
:
shutil
.
copyfile
(
srcFile
,
destFile
)
except
Exception
as
e
:
sickrage
.
app
.
log
.
warning
(
str
(
e
))
shutil
.
copyfile
(
src_file
,
dest_file
)
except
OSError
as
e
:
if
e
.
errno
==
errno
.
ENOSPC
:
sickrage
.
app
.
log
.
warning
(
e
)
else
:
sickrage
.
app
.
log
.
error
(
e
)
else
:
try
:
shutil
.
copymode
(
src
F
ile
,
dest
F
ile
)
shutil
.
copymode
(
src
_f
ile
,
dest
_f
ile
)
except
OSError
:
pass
def
move
F
ile
(
src
F
ile
,
dest
F
ile
):
def
move
_f
ile
(
src
_f
ile
,
dest
_f
ile
):
"""
Move a file from source to destination
:param src
F
ile: Path of source file
:param dest
F
ile: Path of destination file
:param src
_f
ile: Path of source file
:param dest
_f
ile: Path of destination file
"""
try
:
shutil
.
move
(
src
F
ile
,
dest
F
ile
)
fix
SetG
roup
ID
(
dest
F
ile
)
shutil
.
move
(
src
_f
ile
,
dest
_f
ile
)
fix
_set_g
roup
_id
(
dest
_f
ile
)
except
OSError
:
copy
F
ile
(
src
F
ile
,
dest
F
ile
)
os
.
unlink
(
src
F
ile
)
copy
_f
ile
(
src
_f
ile
,
dest
_f
ile
)
os
.
unlink
(
src
_f
ile
)
def
link
(
src
,
dst
):
...
...
@@ -486,21 +490,27 @@ def link(src, dst):
os
.
link
(
src
,
dst
)
def
hardlink
F
ile
(
src
F
ile
,
dest
F
ile
):
def
hardlink
_f
ile
(
src
_f
ile
,
dest
_f
ile
):
"""
Create a hard-link (inside filesystem link) between source and destination
:param src
F
ile: Source file
:param dest
F
ile: Destination file
:param src
_f
ile: Source file
:param dest
_f
ile: Destination file
"""
try
:
link
(
srcFile
,
destFile
)
fixSetGroupID
(
destFile
)
except
Exception
as
e
:
sickrage
.
app
.
log
.
warning
(
"Failed to create hardlink of %s at %s. Error: %r. Copying instead"
%
(
srcFile
,
destFile
,
e
))
copyFile
(
srcFile
,
destFile
)
link
(
src_file
,
dest_file
)
fix_set_group_id
(
dest_file
)
except
OSError
as
e
:
if
e
.
errno
==
errno
.
EEXIST
:
# File exists. Don't fallback to copy
sickrage
.
app
.
log
.
warning
(
'Failed to create hardlink of {src} at {dest}. Error: {error!r}'
.
format
(
**
{
'src'
:
src_file
,
'dest'
:
dest_file
,
'error'
:
e
}))
else
:
sickrage
.
app
.
log
.
warning
(
"Failed to create hardlink of {src} at {dest}. Error: {error!r}. Copying instead"
.
format
(
**
{
'src'
:
src_file
,
'dest'
:
dest_file
,
'error'
:
e
}))
copy_file
(
src_file
,
dest_file
)
def
symlink
(
src
,
dst
):
...
...
@@ -519,23 +529,28 @@ def symlink(src, dst):
os
.
symlink
(
src
,
dst
)
def
move
AndS
ymlink
F
ile
(
src
F
ile
,
dest
F
ile
):
def
move
_and_s
ymlink
_f
ile
(
src
_f
ile
,
dest
_f
ile
):
"""
Move a file from source to destination, then create a symlink back from destination from source. If this fails, copy
the file from source to destination
:param src
F
ile: Source file
:param dest
F
ile: Destination file
:param src
_f
ile: Source file
:param dest
_f
ile: Destination file
"""
try
:
shutil
.
move
(
srcFile
,
destFile
)
fixSetGroupID
(
destFile
)
symlink
(
destFile
,
srcFile
)
except
Exception
as
e
:
sickrage
.
app
.
log
.
warning
(
"Failed to create symlink of %s at %s. Error: %r. Copying instead"
%
(
srcFile
,
destFile
,
e
))
copyFile
(
srcFile
,
destFile
)
shutil
.
move
(
src_file
,
dest_file
)
fix_set_group_id
(
dest_file
)
symlink
(
dest_file
,
src_file
)
except
OSError
as
e
:
if
e
.
errno
==
errno
.
EEXIST
:
# File exists. Don't fallback to copy
sickrage
.
app
.
log
.
warning
(
'Failed to create symlink of {src} at {dest}. Error: {error!r}'
.
format
(
**
{
'src'
:
src_file
,
'dest'
:
dest_file
,
'error'
:
e
}))
else
:
sickrage
.
app
.
log
.
warning
(
"Failed to create symlink of {src} at {dest}. Error: {error!r}. Copying instead"
.
format
(
**
{
'src'
:
src_file
,
'dest'
:
dest_file
,
'error'
:
e
}))
copy_file
(
src_file
,
dest_file
)
def
make_dirs
(
path
):
...
...
@@ -573,7 +588,7 @@ def make_dirs(path):
sickrage
.
app
.
log
.
debug
(
"Folder %s didn't exist, creating it"
%
sofar
)
os
.
mkdir
(
sofar
)
# use normpath to remove end separator, otherwise checks permissions against itself
chmod
AsP
arent
(
os
.
path
.
normpath
(
sofar
))
chmod
_as_p
arent
(
os
.
path
.
normpath
(
sofar
))
# do the library update for synoindex
sickrage
.
app
.
notifier_providers
[
'synoindex'
].
addFolder
(
sofar
)
except
(
OSError
,
IOError
)
as
e
:
...
...
@@ -621,7 +636,7 @@ def delete_empty_folders(check_empty_dir, keep_dir=None):
pass
def
file
BitF
ilter
(
mode
):
def
file
_bit_f
ilter
(
mode
):
"""
Strip special filesystem bits from file
...
...
@@ -636,9 +651,10 @@ def fileBitFilter(mode):
return
mode
def
chmod
AsP
arent
(
child
P
ath
):
def
chmod
_as_p
arent
(
child
_p
ath
):
"""
Retain permissions of parent for childs
(Does not work for Windows hosts)
:param childPath: Child Path to change permissions to sync from parent
...
...
@@ -647,82 +663,85 @@ def chmodAsParent(childPath):
if
os
.
name
==
'nt'
or
os
.
name
==
'ce'
:
return
parent
P
ath
=
os
.
path
.
dirname
(
child
P
ath
)
parent
_p
ath
=
os
.
path
.
dirname
(
child
_p
ath
)
if
not
parent
P
ath
:
sickrage
.
app
.
log
.
debug
(
"No parent path provided in "
+
child
P
ath
+
", unable to get permissions from it"
)
if
not
parent
_p
ath
:
sickrage
.
app
.
log
.
debug
(
"No parent path provided in "
+
child
_p
ath
+
", unable to get permissions from it"
)
return
childPath
=
os
.
path
.
join
(
parentPath
,
os
.
path
.
basename
(
childPath
))
child_path
=
os
.
path
.
join
(
parent_path
,
os
.
path
.
basename
(
child_path
))
if
not
os
.
path
.
exists
(
child_path
):
return
parent
P
ath
S
tat
=
os
.
stat
(
parent
P
ath
)
parent
M
ode
=
stat
.
S_IMODE
(
parent
P
ath
S
tat
[
stat
.
ST_MODE
])
parent
_p
ath
_s
tat
=
os
.
stat
(
parent
_p
ath
)
parent
_m
ode
=
stat
.
S_IMODE
(
parent
_p
ath
_s
tat
[
stat
.
ST_MODE
])
child
P
ath
S
tat
=
os
.
stat
(
child
P
ath
)
child
P
ath_mode
=
stat
.
S_IMODE
(
child
P
ath
S
tat
[
stat
.
ST_MODE
])
child
_p
ath
_s
tat
=
os
.
stat
(
child
_p
ath
)
child
_p
ath_mode
=
stat
.
S_IMODE
(
child
_p
ath
_s
tat
[
stat
.
ST_MODE
])
if
os
.
path
.
isfile
(
child
P
ath
):
child
M
ode
=
file
BitF
ilter
(
parent
M
ode
)
if
os
.
path
.
isfile
(
child
_p
ath
)
and
sickrage
.
app
.
config
.
strip_special_file_bits
:
child
_m
ode
=
file
_bit_f
ilter
(
parent
_m
ode
)
else
:
child
M
ode
=
parent
M
ode
child
_m
ode
=
parent
_m
ode
if
child
P
ath_mode
==
child
M
ode
:
if
child
_p
ath_mode
==
child
_m
ode
:
return
child
P
ath_owner
=
child
P
ath
S
tat
.
st_uid
child
_p
ath_owner
=
child
_p
ath
_s
tat
.
st_uid
user_id
=
os
.
geteuid
()
if
user_id
!=
0
and
user_id
!=
child
P
ath_owner
:
sickrage
.
app
.
log
.
debug
(
"Not running as root or owner of "
+
child
P
ath
+
", not trying to set permissions"
)
if
user_id
not
in
(
0
,
child
_p
ath_owner
)
:
sickrage
.
app
.
log
.
debug
(
"Not running as root or owner of "
+
child
_p
ath
+
", not trying to set permissions"
)
return
try
:
os
.
chmod
(
child
P
ath
,
child
M
ode
)
os
.
chmod
(
child
_p
ath
,
child
_m
ode
)
sickrage
.
app
.
log
.
debug
(
"Setting permissions for %s to %o as parent directory has %o"
%
(
child
P
ath
,
child
M
ode
,
parent
M
ode
))
"Setting permissions for %s to %o as parent directory has %o"
%
(
child
_p
ath
,
child
_m
ode
,
parent
_m
ode
))
except
OSError
:
sickrage
.
app
.
log
.
debug
(
"Failed to set permission for %s to %o"
%
(
child
P
ath
,
child
M
ode
))
sickrage
.
app
.
log
.
debug
(
"Failed to set permission for %s to %o"
%
(
child
_p
ath
,
child
_m
ode
))
def
fix
SetG
roup
ID
(
child
P
ath
):
def
fix
_set_g
roup
_id
(
child
_p
ath
):
"""
Inherid SGID from parent
Inherit SGID from parent
(does not work on Windows hosts)
:param child
P
ath: Path to inherit SGID permissions from parent
:param child
_p
ath: Path to inherit SGID permissions from parent
"""
if
os
.
name
==
'nt'
or
os
.
name
==
'ce'
:
return
parent
P
ath
=
os
.
path
.
dirname
(
child
P
ath
)
parent
S
tat
=
os
.
stat
(
parent
P
ath
)
parent
M
ode
=
stat
.
S_IMODE
(
parent
S
tat
[
stat
.
ST_MODE
])
parent
_p
ath
=
os
.
path
.
dirname
(
child
_p
ath
)
parent
_s
tat
=
os
.
stat
(
parent
_p
ath
)
parent
_m
ode
=
stat
.
S_IMODE
(
parent
_s
tat
[
stat
.
ST_MODE
])
child
P
ath
=
os
.
path
.
join
(
parent
P
ath
,
os
.
path
.
basename
(
child
P
ath
))
child
_p
ath
=
os
.
path
.
join
(
parent
_p
ath
,
os
.
path
.
basename
(
child
_p
ath
))
if
parent
M
ode
&
stat
.
S_ISGID
:
parent
GID
=
parent
S
tat
[
stat
.
ST_GID
]
child
S
tat
=
os
.
stat
(
child
P
ath
)
child
GID
=
child
S
tat
[
stat
.
ST_GID
]
if
parent
_m
ode
&
stat
.
S_ISGID
:
parent
_gid
=
parent
_s
tat
[
stat
.
ST_GID
]
child
_s
tat
=
os
.
stat
(
child
_p
ath
)
child
_gid
=
child
_s
tat
[
stat
.
ST_GID
]
if
child
GID
==
parent
GID
:
if
child
_gid
==
parent
_gid
:
return
child
P
ath_owner
=
child
S
tat
.
st_uid
child
_p
ath_owner
=
child
_s
tat
.
st_uid
user_id
=
os
.
geteuid
()
if
user_id
!=
0
and
user_id
!=
child
P
ath_owner
:
if
user_id
not
in
(
0
,
child
_p
ath_owner
)
:
sickrage
.
app
.
log
.
debug
(
"Not running as root or owner of {}, not trying to set the set-group-ID"
.
format
(
child
P
ath
))
"Not running as root or owner of {}, not trying to set the set-group-ID"
.
format
(
child
_p
ath
))
return
try
:
os
.
chown
(
child
P
ath
,
-
1
,
parent
GID
)
# @UndefinedVariable - only available on UNIX
sickrage
.
app
.
log
.
debug
(
"Respecting the set-group-ID bit on the parent directory for {}"
.
format
(
child
P
ath
))
os
.
chown
(
child
_p
ath
,
-
1
,
parent
_gid
)
sickrage
.
app
.
log
.
debug
(
"Respecting the set-group-ID bit on the parent directory for {}"
.
format
(
child
_p
ath
))
except
OSError
:
sickrage
.
app
.
log
.
error
(
"Failed to respect the set-group-ID bit on the parent directory for {} (setting "
"group ID {})"
.
format
(
child
P
ath
,
parent
GID
))
"group ID {})"
.
format
(
child
_p
ath
,
parent
_gid
))
def
sanitizeSceneName
(
name
,
anime
=
False
):
...
...
@@ -948,7 +967,7 @@ def restoreConfigZip(archive, targetDir, restore_database=True, restore_config=T
return
tail
or
os
.
path
.
basename
(
head
)
bakFilename
=
'{0}-{1}'
.
format
(
path_leaf
(
targetDir
),
datetime
.
datetime
.
now
().
strftime
(
'%Y%m%d_%H%M%S'
))
move
F
ile
(
targetDir
,
os
.
path
.
join
(
os
.
path
.
dirname
(
targetDir
),
bakFilename
))
move
_f
ile
(
targetDir
,
os
.
path
.
join
(
os
.
path
.
dirname
(
targetDir
),
bakFilename
))
with
zipfile
.
ZipFile
(
archive
,
'r'
,
allowZip64
=
True
)
as
zip_file
:
for
member
in
zip_file
.
namelist
():
...
...
@@ -1029,26 +1048,26 @@ def restoreSR(srcDir, dstDir):
if
os
.
path
.
exists
(
srcFile
):
if
os
.
path
.
isfile
(
dstFile
):
move
F
ile
(
dstFile
,
bakFile
)
move
F
ile
(
srcFile
,
dstFile
)
move
_f
ile
(
dstFile
,
bakFile
)
move
_f
ile
(
srcFile
,
dstFile
)
# databse
if
os
.
path
.
exists
(
os
.
path
.
join
(
srcDir
,
'database'
)):
if
os
.
path
.
exists
(
os
.
path
.
join
(
dstDir
,
'database'
)):
move
F
ile
(
os
.
path
.
join
(
dstDir
,
'database'
),
os
.
path
.
join
(
dstDir
,
'{}.bak-{}'
.
format
(
'database'
,
move
_f
ile
(
os
.
path
.
join
(
dstDir
,
'database'
),
os
.
path
.
join
(
dstDir
,
'{}.bak-{}'
.
format
(
'database'
,
datetime
.
datetime
.
now
().
strftime
(
'%Y%m%d_%H%M%S'
))))
move
F
ile
(
os
.
path
.
join
(
srcDir
,
'database'
),
dstDir
)
move
_f
ile
(
os
.
path
.
join
(
srcDir
,
'database'
),
dstDir
)
# cache
if
os
.
path
.
exists
(
os
.
path
.
join
(
srcDir
,
'cache'
)):
if
os
.
path
.
exists
(
os
.
path
.
join
(
dstDir
,
'cache'
)):
move
F
ile
(
os
.
path
.
join
(
dstDir
,
'cache'
),
os
.
path
.
join
(
dstDir
,
'{}.bak-{}'
.
format
(
'cache'
,
move
_f
ile
(
os
.
path
.
join
(
dstDir
,
'cache'
),
os
.
path
.
join
(
dstDir
,
'{}.bak-{}'
.
format
(
'cache'
,
datetime
.
datetime
.
now
().
strftime
(
'%Y%m%d_%H%M%S'
))))
move
F
ile
(
os
.
path
.
join
(
srcDir
,
'cache'
),
dstDir
)
move
_f
ile
(
os
.
path
.
join
(
srcDir
,
'cache'
),
dstDir
)
return
True
except
Exception
as
e
:
...
...
@@ -1357,7 +1376,7 @@ def restoreVersionedFile(backup_file, version):
sickrage
.
app
.
log
.
debug
(
"Trying to backup %s to %s.r%s before restoring backup"
%
(
new_file
,
new_file
,
version
))
move
F
ile
(
new_file
,
new_file
+
'.'
+
'r'
+
str
(
version
))
move
_f
ile
(
new_file
,
new_file
+
'.'
+
'r'
+
str
(
version
))
except
Exception
as
e
:
sickrage
.
app
.
log
.
warning
(
"Error while trying to backup file %s before proceeding with restore: %r"
%
(
restore_file
,
e
))
...
...
@@ -1833,4 +1852,4 @@ def episode_num(season=None, episode=None, **kwargs):
return
'S{0:0>2}E{1:02}'
.
format
(
season
,
episode
)
elif
numbering
==
'absolute'
:
if
not
(
season
and
episode
)
and
(
season
or
episode
):
return
'{0:0>3}'
.
format
(
season
or
episode
)
\ No newline at end of file
return
'{0:0>3}'
.
format
(
season
or
episode
)
sickrage/core/processors/post_processor.py
View file @
eca1d42f
...
...
@@ -31,7 +31,8 @@ from sickrage.core.common import Quality, ARCHIVED, DOWNLOADED
from
sickrage.core.exceptions
import
EpisodeNotFoundException
,
EpisodePostProcessingFailedException
,
\
NoFreeSpaceException
from
sickrage.core.helpers
import
findCertainShow
,
show_names
,
replaceExtension
,
makeDir
,
\
chmodAsParent
,
moveFile
,
copyFile
,
hardlinkFile
,
moveAndSymlinkFile
,
remove_non_release_groups
,
remove_extension
,
\
chmod_as_parent
,
move_file
,
copy_file
,
hardlink_file
,
move_and_symlink_file
,
remove_non_release_groups
,
\
remove_extension
,
\
isFileLocked
,
verify_freespace
,
delete_empty_folders
,
make_dirs
,
symlink
,
is_rar_file
,
glob_escape
from
sickrage.core.nameparser
import
InvalidNameException
,
InvalidShowException
,
\
NameParser
...
...
@@ -365,7 +366,7 @@ class PostProcessor(object):
if
not
dir_exists
:
sickrage
.
app
.
log
.
warning
(
"Unable to create subtitles folder "
+
subs_new_path
)
else
:
chmod
AsP
arent
(
subs_new_path
)
chmod
_as_p
arent
(
subs_new_path
)
new_file_path
=
os
.
path
.
join
(
subs_new_path
,
new_file_name
)
else
:
new_file_path
=
os
.
path
.
join
(
new_path
,
new_file_name
)
...
...
@@ -386,8 +387,8 @@ class PostProcessor(object):
self
.
_log
(
"Moving file from "
+
cur_file_path
+
" to "
+
new_file_path
,
sickrage
.
app
.
log
.
DEBUG
)
try
:
move
F
ile
(
cur_file_path
,
new_file_path
)
chmod
AsP
arent
(
new_file_path
)
move
_f
ile
(
cur_file_path
,
new_file_path
)
chmod
_as_p
arent
(
new_file_path
)
except
(
IOError
,
OSError
)
as
e
:
self
.
_log
(
"Unable to move file {} to {}: {}"
.
format
(
cur_file_path
,
new_file_path
,
e
),
sickrage
.
app
.
log
.
WARNING
)
...
...
@@ -410,8 +411,8 @@ class PostProcessor(object):
self
.
_log
(
"Copying file from "
+
cur_file_path
+
" to "
+
new_file_path
,
sickrage
.
app
.
log
.
DEBUG
)
try
:
copy
F
ile
(
cur_file_path
,
new_file_path
)
chmod
AsP
arent
(
new_file_path
)
copy
_f
ile
(
cur_file_path
,
new_file_path
)
chmod
_as_p
arent
(
new_file_path
)
except
(
IOError
,
OSError
)
as
e
:
self
.
_log
(
"Unable to copy file {} to {}: {}"
.
format
(
cur_file_path
,
new_file_path
,
e
),
sickrage
.
app
.
log
.
WARNING
)
...
...
@@ -438,8 +439,8 @@ class PostProcessor(object):
if
os
.
path
.
exists
(
new_file_path
):
os
.
remove
(
new_file_path
)
hardlink
F
ile
(
cur_file_path
,
new_file_path
)
chmod
AsP
arent
(
new_file_path
)
hardlink
_f
ile
(
cur_file_path
,
new_file_path
)
chmod
_as_p
arent
(
new_file_path
)
except
(
IOError
,
OSError
)
as
e
:
self
.
_log
(
"Unable to hardlink file {} to {}: {}"
.
format
(
cur_file_path
,
new_file_path
,
e
),
sickrage
.
app
.
log
.
WARNING
)
...
...
@@ -463,8 +464,8 @@ class PostProcessor(object):
self
.
_log
(
"Moving then symbolic linking file from "
+
cur_file_path
+
" to "
+
new_file_path
,
sickrage
.
app
.
log
.
DEBUG
)
try
:
move
AndS
ymlink
F
ile
(
cur_file_path
,
new_file_path
)
chmod
AsP
arent
(
new_file_path
)
move
_and_s
ymlink
_f
ile
(
cur_file_path
,
new_file_path
)
chmod
_as_p
arent
(
new_file_path
)
except
(
IOError
,
OSError
)
as
e
:
self
.
_log
(
"Unable to move and symlink file {} to {}: {}"
.
format
(
cur_file_path
,
new_file_path
,
e
),
sickrage
.
app
.
log
.
WARNING
)
...
...
@@ -492,7 +493,7 @@ class PostProcessor(object):
os
.
remove
(
new_file_path
)
symlink
(
cur_file_path
,
new_file_path
)
chmod
AsP
arent
(
cur_file_path
)
chmod
_as_p
arent
(
cur_file_path
)
except
(
IOError
,
OSError
)
as
e
:
self
.
_log
(
"Unable to symlink file {} to {}: {}"
.
format
(
cur_file_path
,
new_file_path
,
e
),
sickrage
.
app
.
log
.
WARNING
)
...
...
@@ -1050,7 +1051,7 @@ class PostProcessor(object):
try
:
os
.
mkdir
(
ep_obj
.
show
.
location
)
chmod
AsP
arent
(
ep_obj
.
show
.
location
)
chmod
_as_p
arent
(
ep_obj
.
show
.
location
)
# do the library update for synoindex
sickrage
.
app
.
notifier_providers
[
'synoindex'
].
addFolder
(
ep_obj
.
show
.
location
)
...
...
sickrage/core/searchers/trakt_searcher.py
View file @
eca1d42f
...
...
@@ -26,7 +26,7 @@ from datetime import date
import
sickrage
from
sickrage.core.common
import
Quality
from
sickrage.core.common
import
SKIPPED
,
WANTED
,
UNKNOWN
from
sickrage.core.helpers
import
findCertainShow
,
sanitizeFileName
,
makeDir
,
chmod
AsP
arent
from
sickrage.core.helpers
import
findCertainShow
,
sanitizeFileName
,
makeDir
,
chmod
_as_p
arent
from
sickrage.core.queues.search
import
BacklogQueueItem
from
sickrage.core.traktapi
import
srTraktAPI
from
sickrage.indexers
import
IndexerApi
...
...
@@ -428,7 +428,7 @@ class TraktSearcher(object):
sickrage
.
app
.
log
.
warning
(
"Unable to create the folder %s , can't add the show"
%
showPath
)
return
else
:
chmod
AsP
arent
(
showPath
)
chmod
_as_p
arent
(
showPath
)
sickrage
.
app
.
show_queue
.
addShow
(
int
(
indexer
),
int
(
indexer_id
),
showPath
,
default_status
=
status
,
...
...
sickrage/core/tv/episode/__init__.py
View file @
eca1d42f
...
...
@@ -34,7 +34,7 @@ from sickrage.core.exceptions import NoNFOException, \
EpisodeNotFoundException
,
EpisodeDeletedException
from
sickrage.core.helpers
import
is_media_file
,
try_int
,
replaceExtension
,
\
touchFile
,
sanitizeSceneName
,
remove_non_release_groups
,
remove_extension
,
sanitizeFileName
,
\
safe_getattr
,
make_dirs
,
move
F
ile
,
delete_empty_folders
safe_getattr
,
make_dirs
,
move
_f
ile
,
delete_empty_folders
from
sickrage.core.nameparser
import
NameParser
,
InvalidNameException
,
InvalidShowException
from
sickrage.core.processors.post_processor
import
PostProcessor
from
sickrage.core.scene_numbering
import
get_scene_absolute_numbering
,
get_scene_numbering
...
...
@@ -1390,7 +1390,7 @@ class TVEpisode(object):
# move the file
try
:
sickrage
.
app
.
log
.
info
(
"Renaming file from %s to %s"
%
(
cur_path
,
new_path
))
move
F
ile
(
cur_path
,
new_path
)
move
_f
ile
(
cur_path
,
new_path
)
except
(
OSError
,
IOError
)
as
e
:
sickrage
.
app
.
log
.
warning
(
"Failed renaming %s to %s : %r"
%
(
cur_path
,
new_path
,
e
))
return
False
...
...
sickrage/core/webserver/api.py
View file @
eca1d42f
...
...
@@ -46,7 +46,7 @@ from sickrage.core.common import ARCHIVED, DOWNLOADED, IGNORED, \
WANTED
,
dateFormat
,
dateTimeFormat
,
get_quality_string
,
statusStrings
,
\
timeFormat
from
sickrage.core.exceptions
import
CantUpdateShowException
,
CantRemoveShowException
,
CantRefreshShowException
from
sickrage.core.helpers
import
chmod
AsP
arent
,
findCertainShow
,
makeDir
,
\
from
sickrage.core.helpers
import
chmod
_as_p
arent
,
findCertainShow
,
makeDir
,
\
pretty_filesize
,
sanitizeFileName
,
srdatetime
,
try_int
,
readFileBuffered
,
app_statistics
from
sickrage.core.media.banner
import
Banner
from
sickrage.core.media.fanart
import
FanArt
...
...
@@ -2075,7 +2075,7 @@ class CMD_ShowAddNew(ApiCall):
return
_responds
(
RESULT_FAILURE
,
{
"path"
:
showPath
},
"Unable to create the folder "
+
showPath
+
", can't add the show"
)
else
:
chmod
AsP
arent
(
showPath
)
chmod
_as_p
arent
(
showPath
)
sickrage
.
app
.
show_queue
.
addShow
(
int
(
indexer
),
int
(
self
.
indexerid
),
showPath
,
default_status
=
newStatus
,
quality
=
newQuality
,
...
...
sickrage/core/webserver/views.py
View file @
eca1d42f
...
...
@@ -58,7 +58,7 @@ from sickrage.core.common import FAILED, IGNORED, Overview, Quality, SKIPPED, \
from
sickrage.core.exceptions
import
CantRefreshShowException
,
\
CantUpdateShowException
,
EpisodeDeletedException
,
\
NoNFOException
,
CantRemoveShowException
from
sickrage.core.helpers
import
argToBool
,
backupSR
,
chmod
AsP
arent
,
findCertainShow
,
generateApiKey
,
\
from
sickrage.core.helpers
import
argToBool
,
backupSR
,
chmod
_as_p
arent
,
findCertainShow
,
generateApiKey
,
\
getDiskSpaceUsage
,
makeDir
,
readFileBuffered
,
\
remove_article
,
restoreConfigZip
,
\
sanitizeFileName
,
clean_url
,
try_int
,
torrent_webui_url
,
checkbox_to_value
,
clean_host
,
\
...
...
@@ -74,7 +74,7 @@ from sickrage.core.scene_exceptions import get_scene_exceptions, update_scene_ex
from
sickrage.core.scene_numbering
import
get_scene_absolute_numbering
,
\
get_scene_absolute_numbering_for_show
,
get_scene_numbering
,
\
get_scene_numbering_for_show
,
get_xem_absolute_numbering_for_show
,
\
get_xem_numbering_for_show
,
set_scene_numbering
get_xem_numbering_for_show
,
set_scene_numbering
,
xem_refresh
from
sickrage.core.traktapi
import
srTraktAPI
from
sickrage.core.tv.episode
import
TVEpisode
from
sickrage.core.tv.show.coming_episodes
import
ComingEpisodes
...
...
@@ -1428,7 +1428,8 @@ class Home(WebHandler):
else
:
showObj
.
release_groups
.
set_black_keywords
([])
errors
=
[]
warnings
,
errors
=
[],
[]
with
showObj
.
lock
:
newQuality
=
try_int
(
quality_preset
,
None
)
if
not
newQuality
:
...
...
@@ -1465,7 +1466,7 @@ class Home(WebHandler):
if
os
.
path
.
normpath
(
showObj
.
location
)
!=
os
.
path
.
normpath
(
location
):
sickrage
.
app
.
log
.
debug
(
os
.
path
.
normpath
(
showObj
.
location
)
+
" != "
+
os
.
path
.
normpath
(
location
))