From 2b8bfcfed0dd32b79a8a3ba95cb84adb5ab22811 Mon Sep 17 00:00:00 2001
From: Walter Purcaro <vuolter@gmail.com>
Date: Tue, 28 Oct 2014 17:40:39 +0100
Subject: Code cosmetics: use self.core.api instead self.api (for now)

---
 module/plugins/hooks/IRCInterface.py  | 32 +++++++++++++++-----------------
 module/plugins/hooks/RestartFailed.py |  3 +--
 module/plugins/hoster/BasePlugin.py   | 11 -----------
 3 files changed, 16 insertions(+), 30 deletions(-)

(limited to 'module/plugins')

diff --git a/module/plugins/hooks/IRCInterface.py b/module/plugins/hooks/IRCInterface.py
index 5ff24cc79..4bf2c7866 100644
--- a/module/plugins/hooks/IRCInterface.py
+++ b/module/plugins/hooks/IRCInterface.py
@@ -40,8 +40,6 @@ class IRCInterface(Thread, Hook):
         Thread.__init__(self)
         Hook.__init__(self, core, manager)
         self.setDaemon(True)
-        #   self.sm = core.server_methods
-        self.api = core.api  # todo, only use api
 
 
     def coreReady(self):
@@ -201,7 +199,7 @@ class IRCInterface(Thread, Hook):
 
 
     def event_status(self, args):
-        downloads = self.api.statusDownloads()
+        downloads = self.core.api.statusDownloads()
         if not downloads:
             return ["INFO: There are no active downloads currently."]
 
@@ -227,7 +225,7 @@ class IRCInterface(Thread, Hook):
 
 
     def event_queue(self, args):
-        ps = self.api.getQueueData()
+        ps = self.core.api.getQueueData()
 
         if not ps:
             return ["INFO: There are no packages in queue."]
@@ -240,7 +238,7 @@ class IRCInterface(Thread, Hook):
 
 
     def event_collector(self, args):
-        ps = self.api.getCollectorData()
+        ps = self.core.api.getCollectorData()
         if not ps:
             return ["INFO: No packages in collector!"]
 
@@ -257,7 +255,7 @@ class IRCInterface(Thread, Hook):
 
         info = None
         try:
-            info = self.api.getFileData(int(args[0]))
+            info = self.core.api.getFileData(int(args[0]))
 
         except FileDoesNotExists:
             return ["ERROR: Link doesn't exists."]
@@ -272,7 +270,7 @@ class IRCInterface(Thread, Hook):
         lines = []
         pack = None
         try:
-            pack = self.api.getPackageData(int(args[0]))
+            pack = self.core.api.getPackageData(int(args[0]))
 
         except PackageDoesNotExists:
             return ["ERROR: Package doesn't exists."]
@@ -309,12 +307,12 @@ class IRCInterface(Thread, Hook):
 
 
     def event_start(self, args):
-        self.api.unpauseServer()
+        self.core.api.unpauseServer()
         return ["INFO: Starting downloads."]
 
 
     def event_stop(self, args):
-        self.api.pauseServer()
+        self.core.api.pauseServer()
         return ["INFO: No new downloads will be started."]
 
 
@@ -330,7 +328,7 @@ class IRCInterface(Thread, Hook):
         count_failed = 0
         try:
             id = int(pack)
-            pack = self.api.getPackageData(id)
+            pack = self.core.api.getPackageData(id)
             if not pack:
                 return ["ERROR: Package doesn't exists."]
 
@@ -340,7 +338,7 @@ class IRCInterface(Thread, Hook):
 
         except:
             # create new package
-            id = self.api.addPackage(pack, links, 1)
+            id = self.core.api.addPackage(pack, links, 1)
             return ["INFO: Created new Package %s [#%d] with %d links." % (pack, id, len(links))]
 
 
@@ -349,11 +347,11 @@ class IRCInterface(Thread, Hook):
             return ["ERROR: Use del command like this: del -p|-l <id> [...] (-p indicates that the ids are from packages, -l indicates that the ids are from links)"]
 
         if args[0] == "-p":
-            ret = self.api.deletePackages(map(int, args[1:]))
+            ret = self.core.api.deletePackages(map(int, args[1:]))
             return ["INFO: Deleted %d packages!" % len(args[1:])]
 
         elif args[0] == "-l":
-            ret = self.api.delLinks(map(int, args[1:]))
+            ret = self.core.api.delLinks(map(int, args[1:]))
             return ["INFO: Deleted %d links!" % len(args[1:])]
 
         else:
@@ -366,11 +364,11 @@ class IRCInterface(Thread, Hook):
 
         id = int(args[0])
         try:
-            info = self.api.getPackageInfo(id)
+            info = self.core.api.getPackageInfo(id)
         except PackageDoesNotExists:
             return ["ERROR: Package #%d does not exist." % id]
 
-        self.api.pushToQueue(id)
+        self.core.api.pushToQueue(id)
         return ["INFO: Pushed package #%d to queue." % id]
 
 
@@ -379,10 +377,10 @@ class IRCInterface(Thread, Hook):
             return ["ERROR: Pull package from queue like this: pull <package id>."]
 
         id = int(args[0])
-        if not self.api.getPackageData(id):
+        if not self.core.api.getPackageData(id):
             return ["ERROR: Package #%d does not exist." % id]
 
-        self.api.pullFromQueue(id)
+        self.core.api.pullFromQueue(id)
         return ["INFO: Pulled package #%d from queue to collector." % id]
 
 
diff --git a/module/plugins/hooks/RestartFailed.py b/module/plugins/hooks/RestartFailed.py
index 4c48c7077..81a83e2c9 100644
--- a/module/plugins/hooks/RestartFailed.py
+++ b/module/plugins/hooks/RestartFailed.py
@@ -33,11 +33,10 @@ class RestartFailed(Hook):
 
     def periodical(self):
         self.logInfo(_("Restart failed downloads"))
-        self.api.restartFailed()
+        self.core.api.restartFailed()
 
 
     def setup(self):
-        self.api = self.core.api
         self.interval = self.MIN_INTERVAL
 
 
diff --git a/module/plugins/hoster/BasePlugin.py b/module/plugins/hoster/BasePlugin.py
index 7c6a6c102..63714c437 100644
--- a/module/plugins/hoster/BasePlugin.py
+++ b/module/plugins/hoster/BasePlugin.py
@@ -35,17 +35,6 @@ class BasePlugin(Hoster):
             self.multiDL = False
             return
 
-        # self.__name__    = "NetloadIn"
-        # pyfile.name = "test"
-        # self.html = self.load("http://localhost:9000/short")
-        # self.download("http://localhost:9000/short")
-        # self.api = self.load("http://localhost:9000/short")
-        # self.decryptCaptcha("http://localhost:9000/captcha")
-        #
-        # if pyfile.url == "79":
-        #     self.core.api.addPackage("test", [str(i) for i in xrange(80)], 1)
-        #
-        # return
         if pyfile.url.startswith("http"):
 
             try:
-- 
cgit v1.2.3