# Path: module/plugins/internal/misc.py
# class Expose(object):
#     """
#     Used for decoration to declare rpc services
#     """
#     def __new__(cls, fn, *args, **kwargs):
#         hookManager.addRPC(fn.__module__, fn.__name__, fn.__doc__)
#         return fn
# 
# def encode(value, encoding='utf-8', errors='backslashreplace'):
#     """
#     Unicode string -> encoded string (default to UTF-8)
#     """
#     if isinstance(value, unicode):
#         res = value.encode(encoding, errors)
# 
#     elif isinstance(value, str):
#         decoding = get_console_encoding(sys.stdin.encoding)
#         if encoding == decoding:
#             res = value
#         else:
#             res = transcode(value, decoding, encoding)
# 
#     else:
#         res = str(value)
# 
#     return res
# 
# def exists(path):
#     path = encode(path)
# 
#     if os.path.exists(path):
#         if os.name == "nt":
#             dir, name = os.path.split(path.rstrip(os.sep))
#             return name.upper() in map(str.upper, os.listdir(dir))
#         else:
#             return True
#     else:
#         return False
# 
# def fsjoin(*args):
#     """
#     Like os.path.join, but encoding aware
#     (for safe-joining see `safejoin`)
#     """
#     return encode(os.path.join(*args))
# 
# def threaded(fn):
#     def run(*args, **kwargs):
#         hookManager.startThread(fn, *args, **kwargs)
# 
#     return run


import operator
import os
import re
import sys
import time
from ..internal.Addon import Addon
from ..internal.misc import Expose, encode, exists, fsjoin, threaded
    __authors__ = [("Walter Purcaro", "vuolter@gmail.com")]

    _VERSION = re.compile(r'^\s*__version__\s*=\s*("|\')([\d.]+)\1', re.M)

    # SERVER_URL     = "http://updatemanager.pyload.org"
    SERVER_URL = "http://updatemanager-spyload.rhcloud.com"
    CHECK_INTERVAL = 3 * 60 * 60  #: 3 hours

    def activate(self):
        if self.checkonstart:
            self.pyload.api.pauseServer()
            self.update()

            if self.do_restart is False:
                self.pyload.api.unpauseServer()

        self.periodical.start(10)

    def init(self):
        self.info = {
            'pyload': False,
            'plugins': False,
            'last_check': time.time()}
        self.mtimes = {}  #: Store modification time for each plugin
        self.event_map = {'allDownloadsProcessed': "all_downloads_processed"}

        if self.config.get('checkonstart'):
            self.pyload.api.pauseServer()
            self.checkonstart = True
        else:

# Path: module/plugins/internal/misc.py
# class Expose(object):
#     """
#     Used for decoration to declare rpc services
#     """
#     def __new__(cls, fn, *args, **kwargs):
#         hookManager.addRPC(fn.__module__, fn.__name__, fn.__doc__)
#         return fn
# 
# def encode(value, encoding='utf-8', errors='backslashreplace'):
#     """
#     Unicode string -> encoded string (default to UTF-8)
#     """
#     if isinstance(value, unicode):
#         res = value.encode(encoding, errors)
# 
#     elif isinstance(value, str):
#         decoding = get_console_encoding(sys.stdin.encoding)
#         if encoding == decoding:
#             res = value
#         else:
#             res = transcode(value, decoding, encoding)
# 
#     else:
#         res = str(value)
# 
#     return res
# 
# def exists(path):
#     path = encode(path)
# 
#     if os.path.exists(path):
#         if os.name == "nt":
#             dir, name = os.path.split(path.rstrip(os.sep))
#             return name.upper() in map(str.upper, os.listdir(dir))
#         else:
#             return True
#     else:
#         return False
# 
# def fsjoin(*args):
#     """
#     Like os.path.join, but encoding aware
#     (for safe-joining see `safejoin`)
#     """
#     return encode(os.path.join(*args))
# 
# def threaded(fn):
#     def run(*args, **kwargs):
#         hookManager.startThread(fn, *args, **kwargs)
# 
#     return run


# Path: module/plugins/hooks/UpdateManager.py
import operator
import os
import re
import sys
import time
from ..internal.Addon import Addon
from ..internal.misc import Expose, encode, exists, fsjoin, threaded

    __authors__ = [("Walter Purcaro", "vuolter@gmail.com")]

    _VERSION = re.compile(r'^\s*__version__\s*=\s*("|\')([\d.]+)\1', re.M)

    # SERVER_URL     = "http://updatemanager.pyload.org"
    SERVER_URL = "http://updatemanager-spyload.rhcloud.com"
    CHECK_INTERVAL = 3 * 60 * 60  #: 3 hours

    def activate(self):
        if self.checkonstart:
            self.pyload.api.pauseServer()
            self.update()

            if self.do_restart is False:
                self.pyload.api.unpauseServer()

        self.periodical.start(10)

    def init(self):
        self.info = {
            'pyload': False,
            'plugins': False,
            'last_check': time.time()}
        self.mtimes = {}  #: Store modification time for each plugin
        self.event_map = {'allDownloadsProcessed': "all_downloads_processed"}

        if self.config.get('checkonstart'):
            self.pyload.api.pauseServer()
            self.checkonstart = True
        else:

            self.checkonstart = False