Skip to content

Commit

Permalink
Merge branch 'master' into curl_fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pyblub authored Nov 30, 2017
2 parents 587e3b9 + 52b8df4 commit 4468a0d
Show file tree
Hide file tree
Showing 15 changed files with 35 additions and 28 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
6 changes: 3 additions & 3 deletions pyload/requests/base/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def __init__(self, config, context=None, options=None, logger=None):
self.config = config

# Create a new context if not given
self.context = self.CONTEXT_CLASS if context is None else context
self.context = self.CONTEXT_CLASS() if context is None else context #instantiate CONTEXT_CLASS

# Store options in dict
self.options = {} if options is None else options
Expand All @@ -85,7 +85,7 @@ def __init__(self, config, context=None, options=None, logger=None):
# Last response code
self.code = 0
self.flags = 0
self.__abort = False
self._abort = False
self.init_context()

# TODO: content encoding? Could be handled globally
Expand Down Expand Up @@ -131,7 +131,7 @@ def remove_auth(self):
self.unset_option('auth')

def abort(self):
self.__abort = True
self._abort = True

def reset(self):
"""Resets the context to initial state."""
Expand Down
3 changes: 2 additions & 1 deletion pyload/requests/cookie.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ class CookieJar(SimpleCookie):

def set(self, domain, name, value, path='/', expires=None, secure=False,
tailmatch=False):
self.__dict__[name] = to_str(value)
self.__dict__[name] = dict()
self.__dict__[name]['id'] = to_str(value)
self.__dict__[name]['domain'] = to_str(domain)
self.__dict__[name]['tailmatch'] = 'TRUE' if tailmatch else 'FALSE'
self.__dict__[name]['path'] = to_str(path)
Expand Down
6 changes: 3 additions & 3 deletions pyload/utils/debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ def print_dump(obj, file=None):
print(text)


def _format_framestack(frame=None, limit=None):
def _format_framestack(limit=None):
limit = None if not limit else abs(limit)
stack = []
_, value, tb = sys.exc_info(frame)
_, value, tb = sys.exc_info()
try:
while tb:
stack.append(tb.tb_frame)
Expand All @@ -91,7 +91,7 @@ def _format_framestack(frame=None, limit=None):


def format_framestack(frame=None, limit=None):
framestack = _format_framestack(frame, limit)
framestack = _format_framestack(limit)
stack_desc = []
for frame_name, frame_dump in framestack:
dump = os.linesep.join(
Expand Down
4 changes: 0 additions & 4 deletions pyload/utils/fs.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,10 +321,6 @@ def cleanpy(dirname, recursive=True):


def remove(path, trash=False, ignore_errors=False):
trash = True #: test
print('TRASH')
print(path)

if not os.path.exists(path):
if ignore_errors:
return
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 4468a0d

Please sign in to comment.