Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion kotnetcli/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from bs4 import BeautifulSoup, Comment ## Om webinhoud proper te parsen.

## login rc codes contained in the response html page
from server.rccodes import *
from .server.rccodes import *

import logging
logger = logging.getLogger(__name__)
Expand Down
17 changes: 9 additions & 8 deletions kotnetcli/communicator/coloramac.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
## along with kotnetcli. If not, see <http://www.gnu.org/licenses/>.

import sys
from plaintextc import AbstractPlaintextCommunicator, LoginPlaintextCommunicator, ForgetPlaintextCommunicator
from .plaintextc import AbstractPlaintextCommunicator, LoginPlaintextCommunicator, ForgetPlaintextCommunicator

from colorama import (
Fore,
Expand All @@ -39,7 +39,8 @@ def __init__(self, inst_dict):
self.init_colors(map(lambda x:x.upper(),[ "green", "yellow", "red", "bright" ]))
colorama_init()

def init_colors(self, colorNameList):
def init_colors(self, colorNameMap):
colorNameList = list(colorNameMap)
style = getattr(Style, colorNameList.pop())
err_color = getattr(Fore, colorNameList.pop())
wait_color = getattr(Fore, colorNameList.pop())
Expand Down Expand Up @@ -78,16 +79,16 @@ def fmt_wait(self):
sys.stdout.flush()

def fmt_success(self):
print self.SUCCESS_STYLE + "[" + self.SUCCESS_COLOR + self.OK_STR + \
Fore.RESET + "]" + Style.RESET_ALL
print(self.SUCCESS_STYLE + "[" + self.SUCCESS_COLOR + self.OK_STR + \
Fore.RESET + "]" + Style.RESET_ALL)

def fmt_done(self):
print self.SUCCESS_STYLE + "[" + self.SUCCESS_COLOR + "DONE" + \
Fore.RESET + "]" + Style.RESET_ALL
print(self.SUCCESS_STYLE + "[" + self.SUCCESS_COLOR + "DONE" + \
Fore.RESET + "]" + Style.RESET_ALL)

def fmt_fail(self):
print self.FAIL_STYLE + "[" + self.FAIL_COLOR + "FAIL" + \
Fore.RESET + "]" + Style.RESET_ALL
print(self.FAIL_STYLE + "[" + self.FAIL_COLOR + "FAIL" + \
Fore.RESET + "]" + Style.RESET_ALL)

def fmt_bar(self, percentage):
if percentage <= 10:
Expand Down
10 changes: 5 additions & 5 deletions kotnetcli/communicator/dialogc.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from __future__ import unicode_literals

from dialog import Dialog
from loggerc import LoggerCommunicator
from .loggerc import LoggerCommunicator

DIALOG_MSG_LOGIN_SUCCESS = "Je bent successvol ingelogd."
DIALOG_MSG_FORGET_SUCCESS = "You have succesfully removed your kotnetcli credentials."
Expand Down Expand Up @@ -88,7 +88,7 @@ def update(self):
def eventError(self, string):
self.info = string
## fail the current item and cancel all following ones
self.elements[self.iter.next()] = self.FAIL
self.elements[next(self.iter)] = self.FAIL
for x in self.iter: self.elements[x] = self.CANCEL
self.update()

Expand All @@ -112,17 +112,17 @@ def eventCheckNetworkConnection(self):
self.update()

def eventGetData(self):
self.elements[self.iter.next()] = self.DONE
self.elements[next(self.iter)] = self.DONE
self.overal = 20
self.update()

def eventPostData(self):
self.elements[self.iter.next()] = self.DONE
self.elements[next(self.iter)] = self.DONE
self.overal = 50
self.update()

def eventProcessData(self):
self.elements[self.iter.next()] = self.DONE
self.elements[next(self.iter)] = self.DONE
self.overal = 80
self.update()

Expand Down
2 changes: 1 addition & 1 deletion kotnetcli/communicator/loggerc.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
## You should have received a copy of the GNU General Public License
## along with kotnetcli. If not, see <http://www.gnu.org/licenses/>.

from quietc import QuietCommunicator
from .quietc import QuietCommunicator

import logging
logger = logging.getLogger(__name__)
Expand Down
6 changes: 3 additions & 3 deletions kotnetcli/communicator/plaintextc.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import sys
import cursor

from quietc import QuietCommunicator
from .quietc import QuietCommunicator

class AbstractPlaintextCommunicator(QuietCommunicator):

Expand Down Expand Up @@ -67,13 +67,13 @@ def fmt_generic_bar(self, percentage, style, color, stop_color, stop_style):

aantalStreepjesObvPercentage = int(round(percentagefloat/100.0 * \
lengteVanBalkfloat))
print style + "[" + color + \
print(style + "[" + color + \
"=" * aantalStreepjesObvPercentage + stop_color + \
" " * (lengteVanBalkint-aantalStreepjesObvPercentage) + \
"][" + \
" " * (lengteVanRuimteVoorPercentages - len(percentagestring)) + \
color + percentagestring + "%" + \
stop_color + "]" + stop_style
stop_color + "]" + stop_style)

def fmt_bar(self, percentage):
self.fmt_generic_bar(percentage, "", "", "", "")
Expand Down
4 changes: 3 additions & 1 deletion kotnetcli/communicator/quietc.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,10 @@ def doEventErrorInfo(self, info):

def get_input(self, prompt_str, accept=lambda x: x, pwd=False):
prompt = self.fmt_prompt(prompt_str)
try: input = raw_input
except NameError: pass
while True:
rv = getpass.getpass(prompt) if pwd else raw_input(prompt)
rv = getpass.getpass(prompt) if pwd else input(prompt)
rv = rv.strip()
if accept(rv): break
print(self.fmt_err(self.err_input))
Expand Down
2 changes: 1 addition & 1 deletion kotnetcli/communicator/summaryc.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
## You should have received a copy of the GNU General Public License
## along with kotnetcli. If not, see <http://www.gnu.org/licenses/>.

from loggerc import LoggerCommunicator
from .loggerc import LoggerCommunicator

SUMMARY_MSG_LOGIN = "Login geslaagd."
SUMMARY_MSG_DOWN_UP = "Download: {downl}%, Upload: {upl}%"
Expand Down
2 changes: 1 addition & 1 deletion kotnetcli/frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
from .tools import log
logger = logging.getLogger(__name__)

from __init__ import __version__, __release_name__, __src_url__, __descr__
from .__init__ import __version__, __release_name__, __src_url__, __descr__

## Class encapsulating common CLI arguments for all binaries in the kotnetcli
## distribution.
Expand Down
8 changes: 6 additions & 2 deletions kotnetcli/kotnetcli.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,15 @@
)
from .worker import ( ## Stuurt alle losse componenten aan
LoginWorker,
ForgetCredsWorker
ForgetCredsWorker,
EXIT_FAILURE,
EXIT_SUCCESS
)

from .frontend import AbstractClientFrontEnd

from .__init__ import __src_url__

class KotnetCLI(AbstractClientFrontEnd):

## We create three different groups, whose arguments can't be mixed.
Expand Down Expand Up @@ -121,7 +125,7 @@ def parseArgumenten(self):
## 3. communicator-related flags
try:
co = self.parseCommunicatorFlags(fabriek, argumenten)
except ImportError, e:
except ImportError as e:
logger.error(
"import error when trying to create '%s' communicator: %s\n" \
"Have you installed all the dependencies?\n" \
Expand Down
2 changes: 1 addition & 1 deletion kotnetcli/kotnetgui.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import threading
import logging
from PyQt4 import QtGui, QtCore
from Queue import Queue
from queue import Queue

from .communicator.fabriek import inst_dict
from .communicator.summaryc import AbstractSummaryCommunicator
Expand Down
8 changes: 4 additions & 4 deletions kotnetcli/server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
## along with kotnetcli. If not, see <http://www.gnu.org/licenses/>.

import time
import BaseHTTPServer
import CGIHTTPServer
import http.server
from http.server import HTTPServer, CGIHTTPRequestHandler
import ssl
import os

Expand All @@ -50,8 +50,8 @@ def __init__(self):
def run_server():
## Set up a simple HTTP server that listens for incoming GET/POST requests
## and passes them to the relevant CGI script to prepare the HTML response.
handler = CGIHTTPServer.CGIHTTPRequestHandler
httpd = BaseHTTPServer.HTTPServer((HOST_NAME, PORT_NUMBER), handler)
handler = CGIHTTPRequestHandler
httpd = HTTPServer((HOST_NAME, PORT_NUMBER), handler)

## The development test server is intended to run on localhost, so we can
## simply use a plain unencrypted HTTP connection. The following lines
Expand Down
10 changes: 5 additions & 5 deletions kotnetcli/worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,24 +120,24 @@ def login_resultaten(self, co, creds):
except MaxNumberIPException:
co.eventFailureMaxIP()
sys.exit(EXIT_FAILURE)
except InvalidInstitutionException, e:
except InvalidInstitutionException as e:
co.eventFailureInstitution(creds.getInst())
sys.exit(EXIT_FAILURE)
except KotNetRegisterException, e:
except KotNetRegisterException as e:
co.eventFailureRegister("KotNet", creds.getUser(),
creds.getInst())
sys.exit(EXIT_FAILURE)
except CampusNetRegisterException, e:
except CampusNetRegisterException as e:
co.eventFailureRegister("CampusNet", creds.getUser(),
creds.getInst())
sys.exit(EXIT_FAILURE)
except NoLoginServiceException, e:
except NoLoginServiceException as e:
co.eventFailureLoginService()
sys.exit(EXIT_FAILURE)
except InternalScriptErrorException:
co.eventFailureServerScriptError()
sys.exit(EXIT_FAILURE)
except UnknownRCException, e:
except UnknownRCException as e:
(rccode, html) = e.get_info()
co.eventFailureUnknownRC(rccode, html.encode('utf-8'))
sys.exit(EXIT_FAILURE)
Expand Down
4 changes: 1 addition & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
kotnetgui_desktop.close()

import sys
print sys.prefix
print(sys.prefix)
setup(
name = "kotnetcli",
packages = find_packages(),
Expand Down Expand Up @@ -94,5 +94,3 @@
("/usr/share/icons/", ["kotnetcli/data/kotnetcli.jpg"])
]
)