Private GIT
Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SickRage
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
vlbox
SickRage
Commits
74ab3eaa
Commit
74ab3eaa
authored
Jul 10, 2015
by
Dustyn Gibson
Browse files
Options
Downloads
Patches
Plain Diff
Working on SiCKRAGETV/sickrage-issues#2012
parent
ba840616
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
SickBeard.py
+3
-0
3 additions, 0 deletions
SickBeard.py
sickbeard/network_timezones.py
+20
-28
20 additions, 28 deletions
sickbeard/network_timezones.py
with
23 additions
and
28 deletions
SickBeard.py
+
3
−
0
View file @
74ab3eaa
...
...
@@ -376,6 +376,9 @@ class SickRage(object):
# Fire up all our threads
sickbeard
.
start
()
# Prepopulate network timezones, it isn't thread safe
network_timezones
.
update_network_dict
()
# sure, why not?
if
sickbeard
.
USE_FAILED_DOWNLOADS
:
failed_history
.
trimHistory
()
...
...
This diff is collapsed.
Click to expand it.
sickbeard/network_timezones.py
+
20
−
28
View file @
74ab3eaa
...
...
@@ -149,9 +149,6 @@ def update_network_dict():
_remove_old_zoneinfo
()
_update_zoneinfo
()
d
=
{}
# network timezones are stored in a git submodule
loc
=
helpers
.
real_path
(
ek
.
ek
(
join
,
ek
.
ek
(
os
.
path
.
dirname
,
__file__
),
u
'
../lib/network_timezones/network_timezones.txt
'
))
with
open
(
loc
,
'
r
'
)
as
file
:
...
...
@@ -162,6 +159,7 @@ def update_network_dict():
load_network_dict
()
return
d
=
{}
try
:
for
line
in
data
.
splitlines
():
(
key
,
val
)
=
line
.
decode
(
'
utf-8
'
).
strip
().
rsplit
(
u
'
:
'
,
1
)
...
...
@@ -173,31 +171,25 @@ def update_network_dict():
my_db
=
db
.
DBConnection
(
'
cache.db
'
)
# load current network timezones
old_d
=
dict
(
my_db
.
select
(
'
SELECT * FROM network_timezones
'
))
# list of sql commands to update the network_timezones table
cl
=
[]
for
cur_d
,
cur_t
in
d
.
iteritems
():
h_k
=
old_d
.
has_key
(
cur_d
)
if
h_k
and
cur_t
!=
old_d
[
cur_d
]:
# update old record
cl
.
append
(
[
'
UPDATE network_timezones SET network_name=?, timezone=? WHERE network_name=?
'
,
[
cur_d
,
cur_t
,
cur_d
]])
elif
not
h_k
:
# add new record
cl
.
append
([
'
INSERT INTO network_timezones (network_name, timezone) VALUES (?,?)
'
,
[
cur_d
,
cur_t
]])
if
h_k
:
del
old_d
[
cur_d
]
# remove deleted records
if
len
(
old_d
)
>
0
:
old_items
=
list
(
va
for
va
in
old_d
)
cl
.
append
([
'
DELETE FROM network_timezones WHERE network_name IN (%s)
'
%
'
,
'
.
join
([
'
?
'
]
*
len
(
old_items
)),
old_items
])
# change all network timezone infos at once (much faster)
if
len
(
cl
)
>
0
:
my_db
.
mass_action
(
cl
)
network_list
=
dict
(
my_db
.
select
(
'
SELECT * FROM network_timezones
'
))
queries
=
[]
for
network
,
timezone
in
d
.
iteritems
():
existing
=
network_list
.
has_key
(
network
)
if
not
existing
:
queries
.
append
([
'
INSERT OR IGNORE INTO network_timezones VALUES (?,?)
'
,
[
network
,
timezone
]])
elif
network_list
[
network
]
is
not
timezone
:
queries
.
append
([
'
UPDATE OR IGNORE network_timezones SET timezone = ? WHERE network_name = ?
'
,
[
timezone
,
network
]])
if
existing
:
del
network_list
[
network
]
if
network_list
:
purged
=
list
(
x
for
x
in
network_list
)
queries
.
append
([
'
DELETE FROM network_timezones WHERE network_name IN (%s)
'
%
'
,
'
.
join
([
'
?
'
]
*
len
(
purged
)),
purged
])
if
queries
:
my_db
.
mass_action
(
queries
)
load_network_dict
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment