Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added latest changes

  • Loading branch information...
commit 9ac0a3917d3fb050e8fcf9f95ef3b1cde6b23e39 1 parent 469cf94
Sebastian Ruml authored
View
14 src/app_manager.py
@@ -20,7 +20,7 @@
from api_server import ApiServer
from config import Config
from configuration import Configuration
-from gui import pythondrop_ui
+from systray import Systray
from daemon import Daemon
from web_server import WebServer
import globals
@@ -32,10 +32,6 @@
# Initialize some global variables
globalVars = globals.Globals()
globalVars.baseDir = os.path.dirname(os.path.realpath(__file__))
-globalVars.confDir = os.path.join(os.path.expanduser('~'), '.' + globalVars.appName)
-globalVars.cfgFile = os.path.join(globalVars.confDir, 'config.ini')
-globalVars.cfgDb = os.path.join(globalVars.confDir, 'config.db')
-globalVars.logFile = os.path.join(globalVars.confDir, 'pythondrop.log')
class AppManager(Daemon):
@@ -63,16 +59,18 @@ def run(self):
self._logger.info("Starting PythonDrop v" + self._globals.version + "...")
# Create and start the API server
- self._api_server = ApiServer(self, self._config.tcpListenIp, self._config.tcpListenPort)
+ if self._config.enableApi:
+ self._api_server = ApiServer(self, self._config.tcpListenIp, self._config.tcpListenPort)
# Start the web server
if self._config.enableWebServer:
self._web_server = WebServer()
# Check if the systray should be shown
- if self._config.enableSystray:
+ #if self._config.enableSystray:
+ if True:
self._logger.debug("Creating systray...")
- self._systray = pythondrop_ui.Systray(self._globals)
+ self._systray = Systray(self._globals)
# Create the file watcher
self._fswatcher = FSWatcher(self._configOld)
View
2  src/cli.py
@@ -96,7 +96,7 @@ def create(self):
self._config.add_share(self._args[1], self._args[2], self._args[3], self._args[4])
# Restart PythonDrop
- self.restart()
+ if self.running(): self.restart()
def status(self):
print "PythonDrop v" + self._globs.version
View
10 src/configuration.py
@@ -60,7 +60,6 @@ def __init__(self):
if not os.path.exists(self._globals.cfgDb):
Base.metadata.create_all(self._engine)
self.create_default_config()
- self.add_test_share()
class Share(Base):
__tablename__ = 'shares'
@@ -162,6 +161,15 @@ def set_tcpListenPort(self, port):
tcpListenPort = property(get_tcpListenPort, set_tcpListenPort)
+ def get_enableApi(self):
+ return self.app_settings().enableAPI
+
+ def set_enableApi(self, enable):
+ self.app_settings().enableAPI = enable
+ self._dbSession.commit()
+
+ enableApi = property(get_enableApi, set_enableApi)
+
def get_enableWebserver(self):
return self.app_settings().enableWebServer
View
9 src/globals.py
@@ -14,6 +14,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+import os
globals = None
@@ -23,10 +24,10 @@ def __init__(self):
self.version = '0.2.0'
self.pythondrop = None
self.baseDir = None
- self.confDir = None
- self.cfgFile = None
- self.cfgDb = None
- self.logFile = None
+ self.confDir = os.path.join(os.path.expanduser('~'), '.' + self.appName)
+ self.cfgFile = os.path.join(self.confDir, 'config.ini')
+ self.cfgDb = os.path.join(self.confDir, 'config.db')
+ self.logFile = os.path.join(self.confDir, 'pythondrop.log')
self.config = None
self.argv = None
View
35 src/pythondrop_ui.py → src/systray.py
@@ -1,5 +1,7 @@
#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
# Copyright (C) 2010 - 2012 Sebastian Ruml <sebastian.ruml@gmail.com>
#
# This file is part of the PythonDrop project
@@ -34,12 +36,15 @@
import subprocess
import socket
-from src import config
+from configuration import Configuration
+
+class SystrayUi(QtGui.QDialog):
+ def __init__(self):
+ super(SystrayUi, self).__init__()
-class Systray(QtGui.QDialog):
- def __init__(self, argv):
- super(PythonDropGui, self).__init__()
+ # Get the configuration
+ self._config = Configuration()
self._socket = None
@@ -49,15 +54,8 @@ def __init__(self, argv):
self._remoteUser = None
self._remoteRepositoryPath = None
- self._respath = os.path.join(os.path.dirname(os.path.realpath(__file__)), "res")
-
- if len(argv) < 2:
- raise
-
- self._configFile = argv[1]
-
- # Load settings
- self._config = config.Config(self._configFile)
+ staticPath = os.path.join(os.path.dirname(os.path.realpath(__file__)), "static")
+ self._respath = os.path.join(staticPath, "img")
self.createLocalSettingsGroupBox()
self.createRemoteSettingsGroupBox()
@@ -74,16 +72,13 @@ def __init__(self, argv):
mainLayout.addLayout(self.buttonsLayout)
self.setLayout(mainLayout)
- # Connect to PythonDrop daemon
- self.connect()
-
# Read and apply all settings
- self.loadSettings()
+ #self.loadSettings()
# Show the systray icon
self.trayIcon.show()
- self.setWindowTitle("PythonDrop Preferences")
+ self.setWindowTitle("PythonDrop")
self.resize(500, 300)
self.hide()
@@ -308,7 +303,7 @@ class Systray():
Handles the startup and shutdown of the systray.
"""
def __init__(self, globalObjects):
- command = 'python ' + __file__ + " " + globalObjects.cfgFile
+ command = 'python ' + __file__
self._process = subprocess.Popen(command, shell=True)
def start(self):
@@ -331,7 +326,7 @@ def stop(self):
QtGui.QApplication.setQuitOnLastWindowClosed(False)
- window = Systray(sys.argv)
+ window = SystrayUi()
#window.show()
sys.exit(app.exec_())
except SystemExit:
View
5 src/web_server.py
@@ -43,12 +43,10 @@ def index():
global configuration
shares = configuration.shares
- # TODO: Add check for only one share; then redirect to that share
-
return render_template('home.html', shares=shares)
#@app.route('/shares/')
-@app.route('/shares/<int:share_id>/',methods=['POST', 'GET'])
+@app.route('/shares/<int:share_id>/', methods=['POST', 'GET'])
@app.route('/shares/<int:share_id>/<path:dir>/', methods=['POST', 'GET'])
def shares(share_id=None, dir=None):
global configuration
@@ -82,7 +80,6 @@ def shares(share_id=None, dir=None):
else:
error = "Invalid filename"
- share = get_share_by_id(share_id)
if share is not None:
share_path = share.sync_folder
else:
Please sign in to comment.
Something went wrong with that request. Please try again.