def startDownload(args):

    global module, username
    password = ''

    if len(args) > 0:
        module = args[0]
        username = args[1]

    password = getpass.getpass('Enter password for ' + username + ': ')
    ed = examdownloader.examdownloader('CLI')

    def updateStatus(msg, type='normal'):
        print msg

    def downloadCallback(status, lastfile='', numFiles=0):
        if status:
            updateStatus(
                str(numFiles) + ' papers downloaded successfully!', 'success')
            subprocess.call(['open', '-R', lastfile])
        else:
            updateStatus('Paper not released by Department', 'error')

    ed.getContents(module, username, password, destination, downloadCallback,
                   updateStatus)
Ejemplo n.º 2
0
def startDownload(args):

    global module, username
    password = ''

    if len(args) > 0:
        module = args[0]
        username = args[1]

    password = getpass.getpass('Enter password for ' + username + ': ')
    ed = examdownloader.examdownloader('CLI')

    def updateStatus(msg, type='normal'):
        print msg

    def downloadCallback(status, lastfile='', numFiles=0):
        if status:
            updateStatus(
                str(numFiles) + ' papers downloaded successfully!', 'success')
        else:
            updateStatus('Paper not released by Department', 'error')

    for mod in module:
        destination = '/home/titanx/nus/pyp/' + yearsem + '/' + mod + '/'
        ed.getContents(mod, username, password, destination, downloadCallback,
                       updateStatus)
    def startDownload(self):
        module = self.moduleField.get()
        username = self.usernameField.get()
        password = self.passwordField.get()
        destination = self.destField.get()
        ed = examdownloader.examdownloader('GUI')

        def downloadCallback(status, lastfile='', numFiles=0):
            if status:
                self.updateStatus(str(numFiles) + ' papers downloaded successfully!', 'success')
                subprocess.call(['open', '-R', lastfile])
            else:
                self.updateStatus('Paper not released by Department', 'error')

        thread.start_new_thread(ed.getContents, (module, username, password, destination, downloadCallback, self.updateStatus))
Ejemplo n.º 4
0
def startDownload(module, username, destination, password):

    ed = examdownloader.examdownloader('CLI')

    def updateStatus(msg, type='normal'):
        print msg

    def downloadCallback(status, lastfile='', numFiles=0):
        if status:
            updateStatus(
                str(numFiles) + ' papers downloaded successfully!', 'success')
            subprocess.call(['open', '-R', lastfile])
        else:
            updateStatus('Paper not released by Department', 'error')

    ed.getContents(module, username, password, destination, downloadCallback,
                   updateStatus)
Ejemplo n.º 5
0
    def startDownload(self):
        module = self.moduleField.get()
        username = self.usernameField.get()
        password = self.passwordField.get()
        destination = self.destField.get()
        ed = examdownloader.examdownloader('GUI')

        def downloadCallback(status, lastfile='', numFiles=0):
            if status:
                self.updateStatus(
                    str(numFiles) + ' papers downloaded successfully!',
                    'success')
                subprocess.call(['open', '-R', lastfile])
            else:
                self.updateStatus('Paper not released by Department', 'error')

        thread.start_new_thread(ed.getContents,
                                (module, username, password, destination,
                                 downloadCallback, self.updateStatus))
def startDownload(args):

    global module, username
    password = ""

    if len(args) > 0:
        module = args[0]
        username = args[1]

    password = getpass.getpass("Enter password for " + username + ": ")
    ed = examdownloader.examdownloader("CLI")

    def updateStatus(msg, type="normal"):
        print msg

    def downloadCallback(status, lastfile="", numFiles=0):
        if status:
            updateStatus(str(numFiles) + " papers downloaded successfully!", "success")
            subprocess.call(["open", "-R", lastfile])
        else:
            updateStatus("Paper not released by Department", "error")

    ed.getContents(module, username, password, destination, downloadCallback, updateStatus)