Beispiel #1
0
    def create_sub(self, name, arg):
        self.arg = arg
        self._get_chunks('out.wav')
        files = os.listdir("parts/")
        files = ["parts/" + file for file in files]
        self.total = len(files)
        p = Pool(10)
        subs = []
        for x in tqdm.tqdm(p.imap_unordered(self.transribe, files),
                           total=len(files)):
            #os.system('clear')
            subs.append(x)
        subs = [e.split(',') for e in subs]
        subs = [[int(e[0]), e[1]] for e in subs]
        subs = sorted(subs)
        t = 0
        subtitles = ''
        #print(subs)
        for count, text in subs:
            progress(count, self.total, status='')
            subtitles += str(count) + "\n" + self._get_time(t) + " --> "
            t += 5
            subtitles += self._get_time(t) + "\n"
            subtitles += text

        self._write_sub(name, subtitles)
        os.remove('out.wav')
        return True
Beispiel #2
0
    def build(self, x, outputMask=None):
        '''
            Builds the unit.
            outputMask: array (of size of the amount of time steps and consisting of 0 and 1). If 1, output is of that time step is returned
        '''

        if isinstance(x, (list,)):
            input = x
        else:
            input = tf.unstack(x, x.get_shape()[-2], -2)

        output = []

        for i in range(len(input)):
            helper.progress(i + 1, len(input), status="Building RNN")

            O = self.buildTimeLayer(input[i], bool(i == 0))

            if outputMask == None or outputMask[i] == 1:
                output.append(O)

        if isinstance(x, (list,)):
            return output
        else:
            return tf.stack(output, -2)
Beispiel #3
0
 def makeDataset(self, amount, token):
     x = []
     y = []
     c = {}
     for i in range(0, amount):
         helper.progress(i + 1,
                         amount,
                         status="Creating dataset of size " + str(amount))
         X, Y, C = self.getEntry()
         x.append(X)
         y.append(Y)
         if C in c:
             c[C] += 1
         else:
             c[C] = 0
     return Data(x, y, c)
Beispiel #4
0
def download():

    popup, progress_var, progress_bar = helper.progress(
        "download_link", "Downloading...")
    progress = 0
    progress_var.set(progress)
    progress_bar.update()
    progress_step = float(100.0 / len(selected_items2))

    for each in selected_items2:
        if dropbox._path == "/":
            path = "/" + dropbox._files[each]['name']
        else:
            path = dropbox._path + "/" + dropbox._files[each]['name']
        dropbox.download(path)

        progress += progress_step
        progress_var.set(progress)
        progress_bar.update()
        newroot.update()

    time.sleep(0.1)

    popup.destroy()
    dropbox.list_folder(msg_listbox2)
Beispiel #5
0
def open_pdf():
    popup, progress_var, progress_bar = helper.progress(
        "transfer_file", "Transfering files...")
    progress = 0
    progress_var.set(progress)
    progress_bar.update()
    hutsik = False
    if selected_items1 is None:
        if selected_items2 is None:
            hutsik = True
        else:
            progress_step = float(100.0 / len(selected_items2))
            progress = eginLista2(popup, progress_var, progress_bar,
                                  progress_step, progress)
    elif selected_items2 is None:
        progress_step = float(100.0 / len(selected_items1))
        progress = eginLista1(popup, progress_var, progress_bar, progress_step,
                              progress)
    else:
        progress_step = float(100.0 /
                              (len(selected_items1) + len(selected_items2)))
        progress = eginLista1(popup, progress_var, progress_bar, progress_step,
                              progress)
        progress = eginLista2(popup, progress_var, progress_bar, progress_step,
                              progress)
    popup.destroy()
Beispiel #6
0
def transfer_files():
    popup, progress_var, progress_bar = helper.progress(
        "transfer_file", "Transfering files...")
    progress = 0
    progress_var.set(progress)
    progress_bar.update()
    progress_step = float(100.0 / len(selected_items1))

    for each in selected_items1:
        pdf_name, pdf_file = egela.get_pdf(each)

        progress_bar.update()
        newroot.update()

        if dropbox._path == "/":
            path = "/" + pdf_name
        else:
            path = dropbox._path + "/" + pdf_name
        dropbox.transfer_file(path, pdf_file)

        progress += progress_step
        progress_var.set(progress)
        progress_bar.update()
        newroot.update()

        time.sleep(0.1)

    popup.destroy()
    dropbox.list_folder(msg_listbox2)
    msg_listbox2.yview(tk.END)
Beispiel #7
0
    def get_pdf_refs(self):
        popup, progress_var, progress_bar = helper.progress(
            "get_pdf_refs", "Downloading PDF list...")
        progress = 0
        progress_var.set(progress)
        progress_bar.update()

        print("\n##### 4. ESKAERA (Ikasgairen eGelako orrialde nagusia) #####")
        metodoa = 'GET'
        uria = "https://egela.ehu.eus/course/view.php?id=42336"
        goiburuak = {'Host': 'egela.ehu.eus', 'Cookie': self._cookiea}
        erantzuna = requests.request(metodoa,
                                     uria,
                                     headers=goiburuak,
                                     allow_redirects=False)
        kodea = erantzuna.status_code
        deskribapena = erantzuna.reason
        print(str(kodea) + " " + deskribapena)
        for goiburua in erantzuna.headers:
            print(goiburua + ": " + erantzuna.headers[goiburua])
        edukia = erantzuna.content

        print("\n##### HTML-aren azterketa... #####")
        soup = BeautifulSoup(edukia, 'html.parser')
        item_results = soup.find_all('img',
                                     {'class': 'iconlarge activityicon'})
        for each in item_results:
            if each['src'].find("/pdf") != -1:
                print("\n##### PDF-a bat aurkitu da! #####")
                pdf_link = each.parent['href']
                uria = pdf_link
                headers = {'Host': 'egela.ehu.eus', 'Cookie': self._cookiea}
                erantzuna = requests.get(uria,
                                         headers=headers,
                                         allow_redirects=False)
                print(metodoa + " " + uria)
                kodea = erantzuna.status_code
                deskribapena = erantzuna.reason
                print(str(kodea) + " " + deskribapena)
                edukia = erantzuna.content

                soup2 = BeautifulSoup(edukia, 'html.parser')
                div_pdf = soup2.find('div', {'class': 'resourceworkaround'})
                pdf_link = div_pdf.a['href']
                pdf_izena = pdf_link.split('/')[-1]
                self._refs.append({'link': pdf_link, 'pdf_name': pdf_izena})

            progress += 1.5
            progress_var.set(progress)
            progress_bar.update()
            time.sleep(0.1)

        popup.destroy()
        return self._refs
Beispiel #8
0
def delete_files():

    popup, progress_var, progress_bar = helper.progress(
        "delete_file", "Deleting files...")
    progress = 0
    progress_var.set(progress)
    progress_bar.update()
    progress_step = float(100.0 / len(selected_items2))

    for each in selected_items2:
        if dropbox._path == "/":
            path = "/" + dropbox._files[each]['name']
        else:
            path = dropbox._path + "/" + dropbox._files[each]['name']
            print(path)
        dropbox.delete_file(path)

        progress += progress_step
        progress_var.set(progress)
        progress_bar.update()

    popup.destroy()
    dropbox.list_folder(msg_listbox2)
Beispiel #9
0
    def get_pdf_refs(self):
        popup, progress_var, progress_bar = helper.progress(
            "get_pdf_refs", "Downloading PDF list...")
        progress = 0
        progress_var.set(progress)
        progress_bar.update()

        print("\n##### 4. ESKAERA (Ikasgairen eGelako orrialde nagusia) #####")
        metodoa = 'POST'
        data = ""
        section = 1
        pdf = []
        status = 0
        pdf_kop = 0
        kop = 1
        print("Metodoa: ")
        print(metodoa)
        print(self._cookiea)
        while status != 404 and pdf_kop != kop:
            goiburuak = {
                'Host': 'egela.ehu.eus',
                'Content-Type': 'application/x-www-form-urlencoded',
                'Content-Length': str(len(data)),
                'Cookie': self._cookiea
            }
            uria = "https://egela.ehu.eus/course/view.php?id=48048#section-" + str(
                section)
            # uria = "https://egela.ehu.eus/course/view.php?id=48048"
            # uria = "https://egela.ehu.eus/course/view.php?id=48048"
            print(uria)
            erantzuna = requests.request(metodoa,
                                         uria,
                                         data=data,
                                         headers=goiburuak,
                                         allow_redirects=False)
            edukia = erantzuna.content
            status = erantzuna.status_code
            print(status)

            if erantzuna.status_code == 200:
                print("Asignaturas")
                soup = BeautifulSoup(erantzuna.content, "html.parser")
                pdf_results = soup.find_all("div",
                                            {"class": "activityinstance"})
                # pdf_results = soup.find_all('a', {'class': 'aalink'})
                kop = str(pdf_results).count("pdf")
                print("PDF kop: " + str(kop))

            print("\n##### HTML-aren azterketa... #####")
            soup = BeautifulSoup(edukia, 'html.parser')
            item_results = soup.find_all('img',
                                         {'class': 'iconlarge activityicon'})
            for each in item_results:

                if each['src'].find("/pdf") != -1:
                    print("\n##### PDF-a bat aurkitu da! #####")
                    pdf_link = each.parent['href']
                    uria = pdf_link
                    pdf_kop = pdf_kop + 1
                    if pdf.__contains__(uria):
                        print("PDF hau " + uria + " aurkituta dago jada!")
                    else:
                        headers = {
                            'Host': 'egela.ehu.eus',
                            'Cookie': self._cookiea
                        }
                        erantzuna = requests.get(uria,
                                                 headers=headers,
                                                 allow_redirects=False)
                        status = erantzuna.status_code
                        print(status)
                        if status == 303:
                            pdf_uria = erantzuna.headers['Location']
                            erantzuna = requests.get(pdf_uria,
                                                     headers=headers,
                                                     allow_redirects=False)
                            print(metodoa + " " + uria)
                            kodea = erantzuna.status_code
                            deskribapena = erantzuna.reason
                            print(str(kodea) + " " + deskribapena)
                            pdf_izena = pdf_uria.split('/')[-1]
                            pdf_izena = pdf_izena.replace("%20", "_")
                            self._refs.append({
                                'link': pdf_uria,
                                'pdf_name': pdf_izena
                            })

                        elif 'resource' in uria:
                            print(metodoa + " " + uria)
                            kodea = erantzuna.status_code
                            deskribapena = erantzuna.reason
                            print(str(kodea) + " " + deskribapena)
                            edukia = erantzuna.content
                            # print(edukia)
                            status = erantzuna.status_code
                            soup2 = BeautifulSoup(edukia, 'html.parser')
                            div_pdf = soup2.find(
                                'div', {'class': 'resourceworkaround'})
                            # print(div_pdf)
                            if "href" in str(div_pdf):
                                print(div_pdf)
                                div2 = str(div_pdf)
                                length = 5
                                indice_1 = div2.find("href=" "")
                                indice_1 = indice_1 + length + 1
                                print(indice_1)
                                indice_2 = div2.index("onclick")
                                indice_2 = indice_2 - 2
                                print(indice_2)
                                subcadena = div2[indice_1:indice_2]
                                print(subcadena)
                                pdf_link = subcadena
                                print(subcadena)
                                # pdf_link = div_pdf.a['href']
                                pdf_izena = pdf_link.split('/')[-1]
                                pdf_izena = pdf_izena.replace("%20", "_")
                                self._refs.append({
                                    'link': pdf_uria,
                                    'pdf_name': pdf_izena
                                })
                        else:
                            print(metodoa + " " + uria)
                            kodea = erantzuna.status_code
                            deskribapena = erantzuna.reason
                            print(str(kodea) + " " + deskribapena)
                            edukia = erantzuna.content
                            # print(edukia)
                            status = erantzuna.status_code
                            soup2 = BeautifulSoup(edukia, 'html.parser')
                            div_pdf = soup2.find('div',
                                                 {'class': 'urlworkaround'})
                            # print(div_pdf)
                            if "href" in str(div_pdf):
                                print(div_pdf)
                                div2 = str(div_pdf)
                                length = 5
                                indice_1 = div2.find("href=" "")
                                indice_1 = indice_1 + length + 1
                                print(indice_1)
                                indice_2 = div2.index(">h")
                                indice_2 = indice_2 - 1
                                print(indice_2)
                                subcadena = div2[indice_1:indice_2]
                                print(subcadena)
                                pdf_link = subcadena
                                print(subcadena)
                                # pdf_link = div_pdf.a['href']
                                pdf_izena = pdf_link.split('/')[-1]
                                pdf_izena = pdf_izena.replace("%20", "_")
                                self._refs.append({
                                    'link': pdf_link,
                                    'pdf_name': pdf_izena
                                })

                        pdf.append(uria)

                progress += (100 // kop)
                progress_var.set(progress)
                progress_bar.update()
                time.sleep(0.1)

            section = section + 1

        popup.destroy()
        return self._refs
Beispiel #10
0
# coding: utf-8
import datetime

from helper import get_mysql_addr, start, info, err, end, progress, traceback, get_local_ip
import os

bak_dir = 'db_backup/'
if __name__ == '__main__':
    try:
        start()

        db_user = '******'
        db_pwd = 'iraindb10241GB'

        progress(5, '开始获取数据库地址')
        db_ip, db_port = get_mysql_addr()
        progress(10, '获取成功')

        info('数据库 %s : %d' % (db_ip, db_port))

        if not os.path.exists(bak_dir):
            progress(25, '未找到 %s 目录,自动创建该目录' % bak_dir)
            os.makedirs(bak_dir)

        progress(40, '开始进行备份,过程中将使得数据库不可用,进出车将无法正常工作')

        f_path = os.path.join(
            bak_dir, '%s.sql' % str(datetime.datetime.now()).replace(' ', '_'))
        os.system('mysqldump -u%s -p%s -h%s irain_park > %s' %
                  (db_user, db_pwd, db_ip, f_path))
Beispiel #11
0
    def check_credentials(self, username, password, event=None):

        popup, progress_var, progress_bar = helper.progress(
            "check_credentials", "Logging into eGela...")
        progress = 0
        progress_var.set(progress)
        progress_bar.update()

        #-------------------------------------------------------------

        print("##### 1. PETICION #####")
        metodo = 'POST'
        uri = "https://egela.ehu.eus/login/index.php"

        cabeceras = {
            'Host': uri.split('/')[2],
            'Content-Type': 'application/x-www-form-urlencoded',
        }

        data = {
            'username': username.get(),
            'password': password.get(),
        }

        data_encoded = urllib.parse.urlencode(data)
        cabeceras['Content-Length'] = str(len(data_encoded))
        respuesta = requests.request(metodo,
                                     uri,
                                     headers=cabeceras,
                                     data=data_encoded,
                                     allow_redirects=False)

        codigo = respuesta.status_code
        descripcion = respuesta.reason

        print(str(codigo) + " " + descripcion)

        for cabecera in respuesta.headers:
            print(cabecera + ": " + respuesta.headers[cabecera])

        print("")

        progress = 33
        progress_var.set(progress)
        progress_bar.update()
        time.sleep(1)

        #------------------------------------------------------------------------

        print("\n##### 2. PETICION #####")

        metodo = 'GET'
        uri = respuesta.headers['Location']
        print('Metodo: ' + metodo)
        print('Uri: ' + uri + '\n')
        cookie = respuesta.headers['Set-Cookie'].split(',')[0]
        cabeceras = {'Host': uri.split('/')[2], 'Cookie': cookie}
        data = ''
        data_encoded = urllib.parse.urlencode(data)
        cabeceras['Content-Length'] = str(len(data_encoded))
        respuesta = requests.request(metodo,
                                     uri,
                                     headers=cabeceras,
                                     data=data_encoded,
                                     allow_redirects=False)

        codigo = respuesta.status_code
        descripcion = respuesta.reason

        print(str(codigo) + " " + descripcion)

        for cabecera in respuesta.headers:
            print(cabecera + ": " + respuesta.headers[cabecera])

        print("")

        progress = 66
        progress_var.set(progress)
        progress_bar.update()
        time.sleep(1)

        #-------------------------------------------------------------------

        print("\n##### 3. PETICION #####")

        if respuesta.headers.__contains__('Location'):

            metodo = 'GET'
            uri = respuesta.headers['Location']
            print('Metodo: ' + metodo)
            print('Uri: ' + uri + '\n')

            cabeceras = {'Host': uri.split('/')[2], 'Cookie': cookie}

            data = ''
            data_encoded = urllib.parse.urlencode(data)
            cabeceras['Content-Length'] = str(len(data_encoded))
            respuesta = requests.request(metodo,
                                         uri,
                                         headers=cabeceras,
                                         data=data_encoded,
                                         allow_redirects=False)

            codigo = respuesta.status_code
            descripcion = respuesta.reason
            contenido = respuesta.content

            print(str(codigo) + " " + descripcion)

            for cabecera in respuesta.headers:
                print(cabecera + ": " + respuesta.headers[cabecera])

            print("")

            progress = 100
            progress_var.set(progress)
            progress_bar.update()
            time.sleep(1)
            popup.destroy()

            if codigo == 200:

                self._login = 1
                self._cookie = cookie
                self._root.destroy()
                print("Login correct!")

        else:
            messagebox.showinfo("Alert Message", "Login incorrect!")
#!/usr/bin/env python
# coding: utf-8

import traceback
import MySQLdb
import paramiko
from helper import info, start, end, err, progress, get_mysql_addr
import threading

if __name__ == "__main__":

    progress(0)
    start()

    try:
        db_ip, db_port = get_mysql_addr()
    except Exception as e:
        err("init param exception %s\n%s" % (e, traceback.format_exc()))

    try:
        conn = MySQLdb.connect(host=db_ip, port=db_port, user='******', passwd='iraindb10241GB', db='irain_park',
                               charset='utf8')
    except Exception as e:
        err("connect mysql exception %s\n%s" % (e, traceback.format_exc()))

    try:
        cursor = conn.cursor()
        cursor.execute("SELECT ip FROM depot_terminal;")
        ip_list = cursor.fetchall()
    except Exception as e:
        err("check terminal ip failuer %s\n%s" % (e, traceback.format_exc()))
Beispiel #13
0
    def get_pdf_refs(self):

        popup, progress_var, progress_bar = helper.progress(
            "get_pdf_refs", "Downloading PDF list...")
        progress = 0
        progress_var.set(progress)
        progress_bar.update()

        print(
            "\n##### 4. PETICION (Página principal de la asignatura en eGela) #####"
        )

        metodo = 'GET'
        uri = 'https://egela.ehu.eus/course/view.php?id=43994'
        print('Metodo: ' + metodo)
        print('Uri: ' + uri + '\n')
        cabeceras = {'Host': uri.split('/')[2], 'Cookie': self._cookie}
        data = ''
        data_encoded = urllib.parse.urlencode(data)
        cabeceras['Content-Length'] = str(len(data_encoded))
        respuesta = requests.request(metodo,
                                     uri,
                                     headers=cabeceras,
                                     data=data_encoded,
                                     allow_redirects=False)

        codigo = respuesta.status_code
        descripcion = respuesta.reason
        contenido = respuesta.content

        print(str(codigo) + " " + descripcion)

        for cabecera in respuesta.headers:
            print(cabecera + ": " + respuesta.headers[cabecera])

        print("")

        print("\n##### Analisis del HTML... #####")

        soup = BeautifulSoup(contenido, 'html.parser')

        links = soup.find_all('a')

        progress_step = float(100.0 / len(links))

        filelink = ''
        self._refs = []

        for link in links:
            imgs = link.find_all('img')
            for img in imgs:
                if ('pdf' in img['src']):
                    filelink = link.get('href')
                    pdf_name = link.span.text

                    self._refs.append({
                        'pdf_name': pdf_name,
                        'pdf_link': filelink
                    })

                    progress += progress_step
                    progress_var.set(progress)
                    progress_bar.update()
                    time.sleep(0.1)

        popup.destroy()
        return self._refs
Beispiel #14
0
    def get_pdf_refs(self):

        popup, progress_var, progress_bar = helper.progress(
            "get_pdf_refs", "Downloading PDF list...")
        progress = 0
        progress_var.set(progress)
        progress_bar.update()

        print("\n##### 4. ESKAERA (Ikasgairen eGelako orrialde nagusia) #####")
        metodo = 'POST'
        datuak = ""
        cookie = self._cookiea
        goiburuak = {
            'Host': 'egela.ehu.eus',
            'Content-Type': 'application/x-www-form-urlencoded',
            'Content-Length': str(len(datuak)),
            "Cookie": cookie
        }

        uri = "https://egela.ehu.eus/course/view.php?id=42336&section=1"  # goian lortutako uri azken sekzioan sartzen da eta hor soilik pdf 1 dago, beraz, eskuz sartu dut lehen sekzioaren uria
        erantzuna = requests.request(metodo,
                                     uri,
                                     data=datuak,
                                     headers=goiburuak,
                                     allow_redirects=False)

        if (erantzuna.status_code == 200):
            print("Web Sistemak")
            soup = BeautifulSoup(erantzuna.content, "html.parser")
            pdf_results = soup.find_all("div", {"class": "activityinstance"})
            kop = str(pdf_results).count("pdf")

        print("PDF kopurua " + str(kop))
        # print("PDF kopurua " + str(len(self._refs)))
        progress_step = float(100.0 / kop)
        # progress_step = float(100.0 / len(self._refs))
        print("\n##### HTML-aren azterketa... #####")

        for pdf in pdf_results:
            if pdf.find(
                    "img",
                {
                    "src":
                    "https://egela.ehu.eus/theme/image.php/fordson/core/1619589309/f/pdf"
                }
            ):  # egelako elementuetatik, pdf bezala agertzen direnak bilatu
                # ACTUALIZAR BARRA DE PROGRESO
                # POR CADA PDF ANIADIDO EN self._refs
                progress += progress_step
                progress_var.set(progress)
                progress_bar.update()
                time.sleep(0.1)

                uri = pdf.find("a")["href"] + "&redirect=1"
                metodo = 'POST'
                datuak = ""
                goiburuak = {
                    'Host': 'egela.ehu.eus',
                    'Content-Type': 'application/x-www-form-urlencoded',
                    'Content-Length': str(len(datuak)),
                    "Cookie": cookie
                }
                erantzuna = requests.request(metodo,
                                             uri,
                                             data=datuak,
                                             headers=goiburuak,
                                             allow_redirects=False)

                pdf_uri = erantzuna.headers['Location']
                pdf_link = pdf_uri.split("mod_resource/content/")[1].split(
                    "/")[1].replace("%20", "_")
                self._refs.append({"pdf_name": pdf_link, "pdf_link": pdf_uri})

        for elem in self._refs:
            print(elem)
        popup.destroy()
        return self._refs
Beispiel #15
0
    def check_credentials(self, username, password, event=None):
        popup, progress_var, progress_bar = helper.progress(
            "check_credentials", "Logging into eGela...")
        progress = 0
        progress_var.set(progress)
        progress_bar.update()

        print("##### 1. ESKAERA #####")
        datuak = {'username': username.get(), 'password': password.get()}
        metodo = 'POST'
        uri = "https://egela.ehu.eus/login/index.php"

        goiburuak = {
            'Host': 'egela.ehu.eus',
            'Content-Type': 'application/x-www-form-urlencoded',
            'Content-Length': str(len(datuak))
        }

        edukia_encoded = urllib.parse.urlencode(datuak)
        goiburuak['Content-Length'] = str(len(edukia_encoded))

        erantzuna = requests.request(metodo,
                                     uri,
                                     data=edukia_encoded,
                                     headers=goiburuak,
                                     allow_redirects=False)

        if erantzuna.status_code == 303:
            uri = erantzuna.headers['Location']
            print("Location : " + uri)
        if "Set-Cookie" in erantzuna.headers:
            cookie = erantzuna.headers["Set-Cookie"].split(';')[0]
            print("Cookie : " + cookie)

        print(str(erantzuna.status_code) + " " + erantzuna.reason)

        progress = 33
        progress_var.set(progress)
        progress_bar.update()
        time.sleep(0.1)

        print("\n##### 2. ESKAERA #####")
        print(uri)
        goiburuak = {
            'Host': 'egela.ehu.eus',
            'Content-Type': 'application/x-www-form-urlencoded',
            'Content-Length': str(len(datuak)),
            "Cookie": cookie
        }

        edukia_encoded = urllib.parse.urlencode(datuak)
        goiburuak['Content-Length'] = str(len(edukia_encoded))

        erantzuna = requests.request(metodo,
                                     uri,
                                     data=edukia_encoded,
                                     headers=goiburuak,
                                     allow_redirects=False)

        if erantzuna.status_code == 303:
            uri = erantzuna.headers['Location']
            print("Location : " + uri)
        if "Set-Cookie" in erantzuna.headers:
            cookie = erantzuna.headers["Set-Cookie"].split(';')[0]
            print("Cookie : " + cookie)
            datuak = ""

        print(str(erantzuna.status_code) + " " + erantzuna.reason)

        progress = 66
        progress_var.set(progress)
        progress_bar.update()
        time.sleep(0.1)

        print("\n##### 3. ESKAERA #####")
        print(uri)
        goiburuak = {
            'Host': 'egela.ehu.eus',
            'Content-Type': 'application/x-www-form-urlencoded',
            'Content-Length': str(len(datuak)),
            "Cookie": cookie
        }

        edukia_encoded = urllib.parse.urlencode(datuak)
        goiburuak['Content-Length'] = str(len(edukia_encoded))

        erantzuna = requests.request(metodo,
                                     uri,
                                     data=edukia_encoded,
                                     headers=goiburuak,
                                     allow_redirects=False)

        print(str(erantzuna.status_code) + " " + erantzuna.reason)

        COMPROBACION_DE_LOG_IN = erantzuna.status_code == 200

        progress = 100
        progress_var.set(progress)
        progress_bar.update()
        time.sleep(0.1)
        popup.destroy()

        if COMPROBACION_DE_LOG_IN:
            self._login = 1
            print(self._login)
            self._cookiea = cookie
            print(self._cookiea)
            self._root.destroy()
        else:
            messagebox.showinfo("Alert Message", "Login incorrect!")
Beispiel #16
0
    def check_credentials(self, username, password, event=None):
        popup, progress_var, progress_bar = helper.progress(
            "check_credentials", "Logging into eGela...")
        progress = 0
        progress_var.set(progress)
        progress_bar.update()

        print("##### 1. ESKAERA #####")
        metodoa = 'POST'
        uria = "https://egela.ehu.eus/login/index.php"
        headers = {
            'Host': 'egela.ehu.eus',
            'Content-Type': 'application/x-www-form-urlencoded',
        }
        data = {'username': username.get(), 'password': password.get()}
        data_encoded = urllib.parse.urlencode(data)
        headers['Content-Length'] = str(len(data_encoded))
        erantzuna = requests.request(metodoa,
                                     uria,
                                     headers=headers,
                                     data=data_encoded,
                                     allow_redirects=False)
        kodea = erantzuna.status_code
        deskribapena = erantzuna.reason
        print(str(kodea) + " " + deskribapena)
        cookie = ""
        location = ""
        for goiburua in erantzuna.headers:
            print(goiburua + ": " + erantzuna.headers[goiburua])
            if goiburua == "Set-Cookie":
                cookie = erantzuna.headers[goiburua].split(";")[0]
            elif goiburua == "Location":
                location = erantzuna.headers[goiburua]
        self._cookiea = cookie
        progress = 33
        progress_var.set(progress)
        progress_bar.update()
        time.sleep(1)

        print("\n##### 2. ESKAERA #####")
        metodoa = 'GET'
        uria = location
        goiburuak = {'Host': uria.split('/')[2], 'Cookie': cookie}
        erantzuna = requests.request(metodoa,
                                     uria,
                                     headers=goiburuak,
                                     allow_redirects=False)
        kodea = erantzuna.status_code
        deskribapena = erantzuna.reason
        print(str(kodea) + " " + deskribapena)
        for goiburua in erantzuna.headers:
            print(goiburua + ": " + erantzuna.headers[goiburua])
            if goiburua == "Set-Cookie":
                cookie = erantzuna.headers[goiburua].split(";")[0]
            elif goiburua == "Location":
                location = erantzuna.headers[goiburua]

        progress = 66
        progress_var.set(progress)
        progress_bar.update()
        time.sleep(0.1)

        print("\n##### 3. ESKAERA #####")
        #metodoa = 'GET'
        uria = location
        goiburuak = {'Host': 'egela.ehu.eus', 'Cookie': self._cookiea}
        erantzuna = requests.request(metodoa,
                                     uria,
                                     headers=goiburuak,
                                     allow_redirects=False)
        kodea = erantzuna.status_code
        deskribapena = erantzuna.reason
        print(str(kodea) + " " + deskribapena)
        #for goiburua in erantzuna.headers:
        #print(goiburua + ": " + erantzuna.headers[goiburua])
        #edukia = erantzuna.content

        progress = 100
        progress_var.set(progress)
        progress_bar.update()
        time.sleep(0.1)
        popup.destroy()
        erantzuna.headers[
            'Location'] = 'https://egela.ehu.eus/course/view.php?id=42336'  #Web sistemak irakasgaiko id-a
        if erantzuna.headers.__contains__('Location'):
            headers = {'Host': 'egela.ehu.eus', 'Cookie': self._cookiea}
            requests.request('GET',
                             erantzuna.headers['Location'],
                             headers=headers,
                             allow_redirects=False)
            self._login = 1
            self._root.destroy()
        else:
            messagebox.showinfo("Alert Message", "Login incorrect!")
Beispiel #17
0
    def check_credentials(self, username, password, event=None):
        popup, progress_var, progress_bar = helper.progress(
            "check_credentials", "Logging into eGela...")
        progress = 0
        progress_var.set(progress)
        progress_bar.update()

        print("##### 1. ESKAERA #####")
        metodoa = 'POST'
        print("Metodoa: ")
        print(metodoa)
        uria = "https://egela.ehu.eus/login/index.php"
        print("Uria: ")
        print(uria)
        headers = {
            'Host': 'egela.ehu.eus',
            'Content-Type': 'application/x-www-form-urlencoded',
        }
        data = {'username': username.get(), 'password': password.get()}
        data_encoded = urllib.parse.urlencode(data)
        headers['Content-Length'] = str(len(data_encoded))
        erantzuna = requests.request(metodoa,
                                     uria,
                                     headers=headers,
                                     data=data_encoded,
                                     allow_redirects=False)
        print(metodoa + " " + uria)
        kodea = erantzuna.status_code
        deskribapena = erantzuna.reason
        print(str(kodea) + " " + deskribapena)
        cookiea = ""
        location = ""
        for goiburua in erantzuna.headers:
            print(goiburua + ": " + erantzuna.headers[goiburua])
            if goiburua == "Set-Cookie":
                cookiea = erantzuna.headers[goiburua].split(";")[0]
            elif goiburua == "Location":
                location = erantzuna.headers[goiburua]
        # self._cookiea = cookiea
        edukia = erantzuna.content
        print("Edukia: ")
        print(edukia)
        # print(cookiea)
        progress = 33
        progress_var.set(progress)
        progress_bar.update()
        time.sleep(1)

        print("\n##### 2. ESKAERA #####")

        metodoa = 'GET'
        print("Metodoa: ")
        print(metodoa)
        uria = location
        goiburuak = {'Host': uria.split('/')[2], 'Cookie': self._cookiea}
        erantzuna = requests.request(metodoa,
                                     uria,
                                     headers=goiburuak,
                                     allow_redirects=False)
        print(metodoa + " " + uria)
        kodea = erantzuna.status_code
        deskribapena = erantzuna.reason
        print(str(kodea) + " " + deskribapena)
        for goiburua in erantzuna.headers:
            print(goiburua + ": " + erantzuna.headers[goiburua])
            if goiburua == "Set-Cookie":
                cookiea = erantzuna.headers[goiburua].split(";")[0]
            elif goiburua == "Location":
                location = erantzuna.headers[goiburua]
        edukia = erantzuna.content
        print("Edukia: ")
        print(edukia)
        # self._cookiea=cookiea

        progress = 66
        progress_var.set(progress)
        progress_bar.update()
        time.sleep(0.1)

        print("\n##### 3. ESKAERA #####")
        metodoa = 'POST'
        print("Metodoa: ")
        print(metodoa)
        uria = location
        goiburuak = {
            'Host': 'egela.ehu.eus',
            'Content-Type': 'application/x-www-form-urlencoded',
            'Content-Length': str(len(data)),
            'Cookie': self._cookiea
        }
        data_encoded = urllib.parse.urlencode(data)
        goiburuak['Content-Length'] = str(len(data_encoded))
        erantzuna = requests.request(metodoa,
                                     uria,
                                     data=data_encoded,
                                     headers=goiburuak,
                                     allow_redirects=False)
        print(metodoa + " " + uria)
        kodea = erantzuna.status_code
        deskribapena = erantzuna.reason
        print(str(kodea) + " " + deskribapena)
        for goiburua in erantzuna.headers:
            print(goiburua + ": " + erantzuna.headers[goiburua])
        edukia = erantzuna.content
        print("Edukia: ")
        print(edukia)
        print(self._cookiea)

        progress = 100
        progress_var.set(progress)
        progress_bar.update()
        time.sleep(0.1)
        popup.destroy()

        if 'Location' in erantzuna.headers:
            uria = erantzuna.headers['Location']
            metodoa = 'POST'
            print("Metodoa: ")
            print(metodoa)
            # uria = location
            goiburuak = {
                'Host': 'egela.ehu.eus',
                'Content-Type': 'application/x-www-form-urlencoded',
                'Content-Length': str(len(data)),
                'Cookie': self._cookiea
            }
            data_encoded = urllib.parse.urlencode(data)
            goiburuak['Content-Length'] = str(len(data_encoded))
            erantzuna = requests.request(metodoa,
                                         uria,
                                         data=data_encoded,
                                         headers=goiburuak,
                                         allow_redirects=False)
            print(metodoa + " " + uria)
            kodea = erantzuna.status_code
            deskribapena = erantzuna.reason
            print(str(kodea) + " " + deskribapena)
            for goiburua in erantzuna.headers:
                print(goiburua + ": " + erantzuna.headers[goiburua])
            edukia = erantzuna.content
            print("Edukia: ")
            print(edukia)
            print(self._cookiea)

            progress = 100
            progress_var.set(progress)
            progress_bar.update()
            time.sleep(0.1)
            popup.destroy()

        if erantzuna.status_code == 200:
            self._login = 1
            self._root.destroy()
        else:
            messagebox.showinfo("Alert Message", "Login incorrect!")
            print("\n")
            print("Login incorrect!")
Beispiel #18
0
    def check_credentials(self, username, password, event=None):

        cookiea = ""
        popup, progress_var, progress_bar = helper.progress(
            "check_credentials", "Logging into eGela...")
        progress = 0
        progress_var.set(progress)
        progress_bar.update()

        print("##### 1. ESKAERA #####")
        metodo = "POST"
        edukia = {'username': username.get(), 'password': password.get()}
        goiburuak = {
            'Host': 'egela.ehu.eus',
            'Content-Type': 'application/x-www-form-urlencoded',
            'Content-Length': str(len(edukia))
        }
        uria = "http://egela.ehu.eus/login/index.php"

        edukia_encoded = urllib.parse.urlencode(edukia)
        goiburuak['Content-Length'] = str(len(edukia_encoded))

        erantzuna = requests.request(metodo,
                                     uria,
                                     headers=goiburuak,
                                     data=edukia_encoded,
                                     allow_redirects=False)

        codigo = erantzuna.status_code
        descripcion = erantzuna.reason
        print(str(codigo) + " " + descripcion)

        if 'Location' in erantzuna.headers:
            uria = erantzuna.headers['Location']
        if 'Set-Cookie' in erantzuna.headers:
            cookiea = erantzuna.headers['Set-Cookie'].split(",")[0]

        progress = 33
        progress_var.set(progress)
        progress_bar.update()
        time.sleep(0.1)

        print("\n##### 2. ESKAERA #####")
        host = "egela.ehu.eus"
        metodo = 'POST'
        goiburuak = {
            'Host': host,
            'Cookie': cookiea,
            'Content-Type': 'application/x-www-form-urlencoded',
            'Content-Length': str(len(edukia))
        }
        edukia_encoded = urllib.parse.urlencode(edukia)
        goiburuak['Content-Length'] = str(len(edukia_encoded))
        erantzuna = requests.request(metodo,
                                     uria,
                                     headers=goiburuak,
                                     data=edukia_encoded,
                                     allow_redirects=False)

        print("metodoa: " + metodo)
        print("uria: " + uria)
        print("edukia: " + edukia_encoded)

        codigo = erantzuna.status_code
        descripcion = erantzuna.reason
        print(str(codigo) + " " + descripcion)

        if 'Location' in erantzuna.headers:
            uria = erantzuna.headers['Location']
        if 'Set-Cookie' in erantzuna.headers:
            cookiea = erantzuna.headers['Set-Cookie'].split(",")[0]

        progress = 66
        progress_var.set(progress)
        progress_bar.update()
        time.sleep(0.1)

        print("\n##### 3. ESKAERA #####")

        metodo = 'GET'
        goiburuak = {'Host': 'egela.ehu.eus', "Cookie": cookiea}
        erantzuna = requests.request(metodo,
                                     uria,
                                     headers=goiburuak,
                                     allow_redirects=False)

        print("HIRUGARREN ESKAERA")
        print("metodoa: " + metodo)
        print("uria: " + uria)
        #print("edukia: " + edukia_encoded)

        if 'Location' in erantzuna.headers:
            uria = erantzuna.headers['Location']
        if 'Set-Cookie' in erantzuna.headers:
            cookiea = erantzuna.headers['Set-Cookie'].split(",")[0]

        erantzuna = requests.request(metodo,
                                     uria,
                                     headers=goiburuak,
                                     allow_redirects=False)

        codigo = erantzuna.status_code
        descripcion = erantzuna.reason
        print(str(codigo) + " " + descripcion)

        progress = 100
        progress_var.set(progress)
        progress_bar.update()
        time.sleep(0.1)
        popup.destroy()

        COMPROBACION_DE_LOG_IN = erantzuna.status_code == 200

        if COMPROBACION_DE_LOG_IN:
            self._login = 1
            print(self._login)
            self._cookie = cookiea
            #print(self._cookiea)
            self._root.destroy()
        else:
            messagebox.showinfo("Alert Message", "Login incorrect!")
Beispiel #19
0
def main():
    local_ip = get_local_ip()
    set_prefix(local_ip)
    progress(5, '本机地址: %s' % local_ip)

    db_ip, db_port = get_mysql_addr()
    progress(15, '数据库地址: %s:%d' % (db_ip, db_port))

    try:
        check_disk_space()

        conn = MySQLdb.connect(host=db_ip,
                               user='******',
                               passwd='iraindb10241GB',
                               db='irain_park',
                               charset='utf8')
        cursor = conn.cursor()

        cursor.execute(
            'select depot_terminal.name from depot_terminal where depot_terminal.ip = "%s"; '
            % local_ip)
        name = cursor.fetchall()

        progress(20, "板子名称:%s" % name[0])
        check_processes()

        progress(30)
        check_vpr_config(cursor, local_ip, db_ip)

        progress(40)
        check_boa_and_serial(cursor, local_ip)

        progress(50)
        check_paramiko()

        progress(60)
        check_network_connection()

        progress(70)
        check_rinetd()

        progress(80)
        check_link_file()

    except Exception, e:
        err("exception![%s]\n%s" % (str(e), traceback.format_exc()))
Beispiel #20
0
    font.height = height

    # borders= xlwt.Borders()
    # borders.left= 6
    # borders.right= 6
    # borders.top= 6
    # borders.bottom= 6

    style.font = font
    # style.borders = borders
    return style


if __name__ == "__main__":

    progress(0)
    start()

    try:
        progress(20)
        db_ip, db_port = get_mysql_addr()
        end_time = sys.argv[1]
    except Exception as e:
        err("init param exception %s\n%s" % (e, traceback.format_exc()))
        end()
        sys.exit(1)

    try:
        progress(40)
        conn = MySQLdb.connect(host=db_ip,
                               port=db_port,