Skip to content

Commit

Permalink
Merge pull request pyload#3016 from pyblub/multiple_minor_fixes
Browse files Browse the repository at this point in the history
many minor fixes
  • Loading branch information
vuolter authored Nov 24, 2017
2 parents 200b4f9 + 126e3b4 commit 52b8df4
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 17 deletions.
5 changes: 2 additions & 3 deletions pyload/config/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def get(self):
def get_default(self):
return self.default

def set(self, value, store=True):
def set(self, value, store=False):
norm_value = self._normalize_value(value)
if self.allowed_values and norm_value not in self.allowed_values:
raise InvalidValueError(value)
Expand Down Expand Up @@ -254,10 +254,9 @@ def __init__(
pass

else:
self.store()
return

self.store()

def _backup_fileconfig(self):
path = self.path
name, ext = os.path.splitext(path)
Expand Down
2 changes: 2 additions & 0 deletions pyload/core/database/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ def __init__(self, func, *args, **kwargs):
self.result = None
self.exception = False

self.pyload = self.args[0].pyload # self.args[0] is DatabaseBackend

# import inspect
# self.frame = inspect.currentframe()

Expand Down
16 changes: 10 additions & 6 deletions pyload/core/datatype/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ class File(BaseObject):
__slots__ = ['_name', '_size', 'abort', 'added', 'error', 'fid',
'fileorder', 'filestatus', 'hash', 'lock', 'manager', 'media',
'owner', 'packageid', 'plugin', 'pluginclass', 'pluginname',
'reconnected', 'status', 'statusname', 'url', 'wait_until']
'pyload', 'reconnected', 'status', 'statusname', 'url',
'wait_until']

@staticmethod
def from_info_data(m, info):
Expand All @@ -138,6 +139,8 @@ def from_info_data(m, info):
file.hash = info.download.hash
file.status = info.download.status
file.error = info.download.error

file.init_plugin()
return file

def __init__(
Expand Down Expand Up @@ -177,8 +180,9 @@ def __init__(

def get_size(self):
"""Get size of download."""
if self.plugin.dl.size is not None:
self.self._size(self.plugin.dl.size)
if self.plugin is not None and self.plugin.dl is not None \
and self.plugin.dl.size is not None:
self.set_size(self.plugin.dl.size)
return self._size

# NOTE: convert size to int
Expand Down Expand Up @@ -209,7 +213,7 @@ def set_name(self, name):

def __repr__(self):
return '<File {0}: {1}@{2}>'.format(
self.id, self.name, self.pluginname)
self.fid, self.name, self.pluginname)

@lock
def init_plugin(self):
Expand Down Expand Up @@ -299,7 +303,7 @@ def finish_if_done(self):
"""Set status to finish and release file if every thread is finished
with it."""
# TODO: this is wrong now, it should check if addons are using it
if self.id in self.pyload.tsm.processing_ids():
if self.fid in self.pyload.tsm.processing_ids():
return False

self.set_status('finished')
Expand All @@ -308,7 +312,7 @@ def finish_if_done(self):
return True

def check_if_processed(self):
self.manager.check_all_links_processed(self.id)
self.manager.check_all_links_processed(self.fid)

@trycatch(0)
def get_speed(self):
Expand Down
4 changes: 2 additions & 2 deletions pyload/core/datatype/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ class Package(BaseObject):
"""Represents a package object at runtime."""
__slots__ = ['added', 'comment', 'comment', 'folder', 'manager', 'name',
'ownerid', 'packageorder', 'password', 'password', 'pid',
'root', 'set_finished', 'shared', 'site', 'site', 'status',
'tags', 'timestamp']
'pyload', 'root', 'set_finished', 'shared', 'site', 'site',
'status', 'tags', 'timestamp']

@staticmethod
def from_info_data(m, info):
Expand Down
1 change: 1 addition & 0 deletions pyload/core/manager/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ def fire(self, event, *args, **kwargs):
"""Dispatches event with args."""
# dispatch the meta event
if event != 'event':
self.pyload.log.debug(event)
self.fire('event', *(event,) + args, **kwargs)

if event in self.events:
Expand Down
2 changes: 1 addition & 1 deletion pyload/core/manager/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def get_collector(self):
@invalidate
def add_links(self, data, pid, owner):
"""
Add links, data = (url, plugin) tuple. Internal method should use API.
Add links, data = [(url, plugin)] list of tuples. Internal method should use API.
"""
self.db.add_links(data, pid, owner)
self.pyload.evm.fire('package:updated', pid)
Expand Down
3 changes: 2 additions & 1 deletion pyload/core/network/hoster.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ def get_info(urls):
def __init__(self, file):
# TODO: file.owner, but it's not correct yet
super(Hoster, self).__init__(file.manager.pyload)
self._ = self.pyload._

self.want_reconnect = False
# enables simultaneous processing of multiple downloads
Expand Down Expand Up @@ -94,7 +95,7 @@ def __init__(self, file):
self.dl = None

# associated file instance, see `File`
self.filename = file
self.file = file
self.thread = None # holds thread in future

# location where the last call to download was saved
Expand Down
2 changes: 1 addition & 1 deletion pyload/core/network/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def parse(self, folder):

def parse_attributes(self, filename, name, folder=''):
"""Parse attribute dict from plugin."""
with io.open(filename, mode='rb') as fp:
with io.open(filename, mode='r') as fp:
content = fp.read()

attrs = BaseAttributes()
Expand Down
6 changes: 4 additions & 2 deletions pyload/core/thread/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def __init__(self, manager):

@property
def running(self):
return self.__running.is_set()
return self.__running

def _handle_abort(self, file):
self.pyload.log.info(
Expand Down Expand Up @@ -190,7 +190,9 @@ def _run(self, file):
def _finalize(self, file):
self.pyload.files.save()
file.check_if_processed()
sys.exc_clear()
if sys.version_info[0] < 3:
# not available in python 3
sys.exc_clear()
# manager could still be waiting for it
self.__running.set()
# only done when job was not put back
Expand Down
2 changes: 1 addition & 1 deletion pyload/core/thread/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def _gen_reports(self, file):

def _zip(self, filepath, reports, dumpdir):
filename = os.path.basename(filepath)
with zipfile.ZipFile(filepath, 'wb') as zip:
with zipfile.ZipFile(filepath, 'w') as zip:
for fname in os.listdir(dumpdir):
try:
arcname = os.path.join(filename, fname)
Expand Down
1 change: 1 addition & 0 deletions requirements/install.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ semver
setuptools>=0.6.39
tld
validators
enum34;python_version<="2.7"

0 comments on commit 52b8df4

Please sign in to comment.