kuuko pushed a commit to branch master.

http://git.enlightenment.org/apps/epour.git/commit/?id=ab89f1a6ec8c90faec24adf2cc39fc7f2170bf68

commit ab89f1a6ec8c90faec24adf2cc39fc7f2170bf68
Author: Kai Huuhko <kai.huu...@gmail.com>
Date:   Wed Jul 2 19:15:36 2014 +0300

    Fix the setup craziness
---
 bin/epour                       |   8 +-
 epour/{__init__.py => Epour.py} |   0
 epour/__init__.py               | 223 ----------------------------------------
 3 files changed, 4 insertions(+), 227 deletions(-)

diff --git a/bin/epour b/bin/epour
index bbe40f2..019d3d9 100755
--- a/bin/epour
+++ b/bin/epour
@@ -2,9 +2,9 @@
 
 import logging
 
-from epour import Epour
+from epour.Epour import Epour
 
-epour = Epour()
-epour.gui.run()
-epour.quit()
+app = Epour()
+app.gui.run()
+app.quit()
 logging.shutdown()
diff --git a/epour/__init__.py b/epour/Epour.py
similarity index 100%
copy from epour/__init__.py
copy to epour/Epour.py
diff --git a/epour/__init__.py b/epour/__init__.py
index e88b910..e69de29 100644
--- a/epour/__init__.py
+++ b/epour/__init__.py
@@ -1,223 +0,0 @@
-#!/usr/bin/python
-#
-#  Epour - A bittorrent client using EFL and libtorrent
-#
-#  Copyright 2012-2014 Kai Huuhko <kai.huu...@gmail.com>
-#
-#  This program is free software; you can redistribute it and/or modify
-#  it under the terms of the GNU General Public License as published by
-#  the Free Software Foundation; either version 3 of the License, or
-#  (at your option) any later version.
-#
-#  This program is distributed in the hope that it will be useful,
-#  but WITHOUT ANY WARRANTY; without even the implied warranty of
-#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#  GNU General Public License for more details.
-#
-#  You should have received a copy of the GNU General Public License
-#  along with this program; if not, write to the Free Software
-#  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
-#  MA 02110-1301, USA.
-#
-
-import sys
-from argparse import ArgumentParser
-parser = ArgumentParser(description="A BitTorrent client.")
-parser.add_argument(
-    '-v', '--verbose', action="count", help="max is -vvv")
-parser.add_argument(
-    '--add-with-dialog', action="store_true",
-    help="Torrents to be added from arguments open a dialog"
-    )
-parser.add_argument(
-    'torrents', nargs="*", help="file path, magnet uri, or info hash",
-    metavar="TORRENT")
-args = parser.parse_args()
-
-from efl.dbus_mainloop import DBusEcoreMainLoop
-
-import dbus
-ml = DBusEcoreMainLoop()
-dbus.set_default_main_loop(ml)
-import dbus.service
-bus = dbus.SessionBus()
-
-try:
-    dbo = bus.get_object("net.launchpad.epour", "/net/launchpad/epour")
-except dbus.exceptions.DBusException:
-    pass
-else:
-    for f in args.torrents:
-        print("Sending %s via dbus".format(f))
-        dbo.AddTorrent(f, dbus_interface="net.launchpad.epour")
-    sys.exit()
-
-import os
-from ConfigParser import SafeConfigParser
-
-from Globals import conf_dir, conf_path, data_dir
-import logging
-
-for d in conf_dir, data_dir:
-    if not os.path.exists(d):
-        os.mkdir(d, 0700)
-
-from session import Session
-from gui import MainInterface
-
-
-class Epour(object):
-    def __init__(self):
-        self.log = self.setup_log()
-        self.conf = self.setup_conf()
-
-        session = self.session = Session(self.conf)
-        session.load_state()
-
-        self.gui = MainInterface(self, session)
-
-        self.dbusname = dbus.service.BusName(
-            "net.launchpad.epour", dbus.SessionBus()
-        )
-        self.dbo = EpourDBus(session, self.gui, self.conf)
-
-        self.session.load_torrents()
-
-        for t in args.torrents:
-            if args.add_with_dialog:
-                self.gui.add_torrent(t)
-            else:
-                add_dict = {
-                    "save_path": self.conf.get("Settings", "storage_path"),
-                    "flags": 592
-                    }
-                if os.path.isfile(t):
-                    self.session.add_torrent_from_file(add_dict, t)
-                elif t.startswith("magnet:"):
-                    self.session.add_torrent_from_magnet(add_dict, t)
-                else:
-                    self.session.add_torrent_from_hash(add_dict, t)
-
-    def setup_log(self):
-        log_level = logging.ERROR
-        if args.verbose:
-            log_level -= 10 * args.verbose
-
-        log = logging.getLogger("epour")
-        log.propagate = False
-        log.setLevel(log_level)
-
-        ch = logging.StreamHandler()
-        ch_formatter = logging.Formatter(
-            '%(name)s: [%(levelname)s] %(message)s'
-            )
-        ch.setFormatter(ch_formatter)
-        ch.setLevel(log_level)
-        log.addHandler(ch)
-
-        fh = logging.FileHandler(os.path.join(data_dir, "epour.log"))
-        fh_formatter = logging.Formatter(
-            '%(asctime)s - %(name)s - %(levelname)s - %(message)s'
-            )
-        fh.setFormatter(fh_formatter)
-        fh.setLevel(logging.ERROR)
-        log.addHandler(fh)
-
-        return log
-
-    def setup_conf(self):
-        conf = SafeConfigParser({
-            "storage_path": os.path.expanduser(
-                os.path.join("~", "Downloads")
-            ),
-            "confirm_exit": str(False),
-            "dialog_add_dbus": str(True),
-            "delete_original": str(False),
-            "listen_low": str(0),
-            "listen_high": str(0),
-        })
-
-        conf.read(conf_path)
-
-        if not conf.has_section("Settings"):
-            conf.add_section("Settings")
-
-        return conf
-
-    def save_conf(self):
-        with open(conf_path, 'wb') as configfile:
-            self.conf.write(configfile)
-
-    def quit(self):
-        session = self.session
-
-        session.pause()
-
-        try:
-            session.save_torrents()
-        except:
-            self.log.exception("Saving torrents failed")
-
-        try:
-            session.save_state()
-        except:
-            self.log.exception("Saving session state failed")
-
-        try:
-            self.save_conf()
-        except:
-            self.log.exception("Saving conf failed")
-
-
-class EpourDBus(dbus.service.Object):
-
-    log = logging.getLogger("epour.dbus")
-
-    def __init__(self, session, gui, conf):
-        self.session = session
-        self.gui = gui
-        self.conf = conf
-        dbus.service.Object.__init__(
-            self, dbus.SessionBus(),
-            "/net/launchpad/epour", "net.launchpad.epour"
-            )
-
-        self.props = {
-        }
-
-    @dbus.service.method(dbus_interface='net.launchpad.epour',
-                         in_signature='s', out_signature='')
-    def AddTorrent(self, t):
-        self.log.info("Adding %s from dbus" % t)
-        #self.session.add_torrent(str(t))
-        try:
-            if self.conf.getboolean("Settings", "dialog_add_dbus"):
-                self.gui.add_torrent(t)
-            else:
-                add_dict = {
-                    "save_path": self.conf.get("Settings", "storage_path"),
-                    "flags": 592
-                    }
-                if os.path.isfile(t):
-                    self.session.add_torrent_from_file(add_dict, t)
-                elif t.startswith("magnet:"):
-                    self.session.add_torrent_from_magnet(add_dict, t)
-                else:
-                    self.session.add_torrent_from_hash(add_dict, t)
-        except Exception:
-            self.log.exception("Error while adding torrent from dbus")
-
-if __name__ == "__main__":
-    efllog = logging.getLogger("efl")
-    efllog.setLevel(logging.INFO)
-    efllog_formatter = logging.Formatter(
-        '%(name)s: [%(levelname)s] %(message)s'
-        )
-    efllog_handler = logging.StreamHandler()
-    efllog_handler.setFormatter(efllog_formatter)
-    efllog.addHandler(efllog_handler)
-
-    epour = Epour()
-    epour.gui.run()
-    epour.quit()
-    logging.shutdown()

-- 


Reply via email to