Beispiel #1
0
def test_callme(get_mock_approvelogin):
    turn_off_autopush()
    app = Application().Start(
        cmd_line=
        u'C:\\Users\\login_test\\Desktop\\Release\\Release\\AuthUiTest.exe login_test'
    )
    window = app.Dialog
    window.Wait('ready')

    button = window[u'Call Me']
    button.SetFocus()
    button.Click()

    time.sleep(10)

    contents = open('msgOutput.txt', 'r').readlines()
    return_code = int(contents[0].strip())
    print return_code

    content_lines = len(contents)
    if content_lines == 1:
        return_code = int(contents[0].strip())
        assert return_code == 1
    elif content_lines:
        return_code = int(contents[0].strip())
        return_msg = contents[1].strip()
        print return_code, return_msg
        assert return_code != 1

    app.Kill_()
Beispiel #2
0
def test_cancel_selectphone_sendpush(get_mock_cancelpush):
    '''
    With autopush enabled, we launch the app, cancel the auto push in progress,select a different phone and send a push
    '''
    turn_on_autopush()
    app = Application().Start(cmd_line=u'C:\\Users\\login_test\\Desktop\\Release\\Release\\AuthUiTest.exe login_test')
    window = app.Dialog
    window.Wait('ready')

    button2 = window.Cancel
    button2.SetFocus()
    button2.Click()

    combobox = window.ComboBox
    combobox.Select(u'Android (XXX-XXX-4349)')
    button = window.Button
    button.Click()

    time.sleep(10)
    app.Kill_()

    contents = open('msgOutput.txt', 'r').readlines()
    return_code = int(contents[0].strip())
    print return_code

    content_lines = len(contents)
    if content_lines == 1:
        return_code = int(contents[0].strip())
        assert return_code == 1
    elif content_lines:
        return_code = int(contents[0].strip())
        return_msg = contents[1].strip()
        print return_code, return_msg
        assert return_code != 1
Beispiel #3
0
def test_sendpasscodes(get_mock_happySleep):
    app = Application().Start(
        cmd_line=
        u'C:\\Users\\login_test\\Desktop\\Release\\Release\\AuthUiTest.exe login_test'
    )
    window = app.Dialog
    #window.Wait('ready')

    button2 = window.Cancel
    button2.SetFocus()
    button2.Click()

    time.sleep(2)

    button = window.Button4
    button.SetFocus()
    button.Click()

    contents = open('msgOutput.txt', 'r').readlines()
    content_lines = len(contents)
    if content_lines == 1:
        return_code = int(contents[0].strip())
        print return_code
        assert return_code == 1
    elif content_lines:
        return_code = int(contents[0].strip())
        return_msg = contents[1].strip()
        print return_code, return_msg
        assert return_code != 1

    app.Kill_()
def launch_game(delay=5):
    x360 = Application().Start(cmd_line=locations.x360dir)
    time.sleep(delay)
    x360.Kill_()

    game = Application().Start(cmd_line=locations.gamedir)
    gwindow = game.Dialog
    gwindow.Wait('ready')
    button = gwindow[u'Play!']
    button.Click()
Beispiel #5
0
 def save_the_picture(self):
     app = Application().Connect(title=u'Save As')
     window = app.Dialog
     window.Wait('ready')
     button = window[u'&Save']
     button.Click()
     time.sleep(1)
     button = window[u'&Yes']
     button.Click()
     time.sleep(1)
     app.Kill_()
Beispiel #6
0
class Monitool:

    def __init__(self):
        self.syst_name = 'ECD'
        self.client = '800'
        self.user = '******'
        self.pw = 'Welcome123'
        self.transactions = []
        print('Hello World')

    def pause(self, seconds):
        time.sleep(seconds)

    def open_sap_logon(self):
        try:
            print("Checking if App is already opened.")
            self.app = Application().Connect(path=r"C:\\Program Files (x86)\\SAP\\FrontEnd\\SAPgui\\saplogon.exe")
            self.dlg = self.app.Dialog
        except:
            print("Opening App.")
            self.app = Application().Start(cmd_line=u'"C:\\Program Files (x86)\\SAP\\FrontEnd\\SAPgui\\saplogon.exe"')
            self.dlg = self.app.Dialog

    def connect_sap_system(self):
        print("Opening system instance.")
        self.dlg.Button7.click()  # list view
        syst_list = self.dlg.listView
        self.pause(2)

        try:
            syst_list.type_keys("{HOME}")
            syst_list.GetItem(self.syst_name).Click()
            self.dlg['Log&On'].Click()
        except ValueError:
            print("Please add system in SAP logon")
            self.app.Kill_()

        print("Login user.")
        sap_frontend_session = self.app.window(class_name='SAP_FRONTEND_SESSION')
        sap_frontend_session.type_keys(self.user + "{TAB}" + self.pw)
        sap_frontend_session.type_keys("{TAB 21}")
        sap_frontend_session.type_keys("^a{BKSP}" + self.client)
        sap_frontend_session.type_keys("{ENTER}")

    def set_system(self, system):
        self.syst_name = system
Beispiel #7
0
def update_version():
    # 목적 : kiwoom의 version update하기 위함.

    # Account : id은 이미 지정되어 있으므로, id password, 공인인증서 password 을 지정을 한다.
    account = []
    with open("../data/account.txt", 'r') as f:
        account = f.readlines()

    # split the newline
    account = [aa.strip() for aa in account]

    app = Application().Start(
        cmd_line=u"C:\\51.키움증권\\KiwoomFlash3\\bin\\nkministarter.exe")
    mainframe = app[u'번개3 login']
    mainframe.Wait('ready')
    time.sleep(2)
    mainframe.Edit2.set_text(account[0])

    time.sleep(2)

    mainframe.Edit3.set_text(account[1])
    time.sleep(2)

    mainframe.Button0.Click()
    time.sleep(30)
    app.Kill_()

    # 업데이트가 완료될 때 까지 대기
    while True:
        time.sleep(5)
        with os.popen('tasklist /FI "IMAGENAME eq nkmini.exe"') as f:
            lines = f.readlines()
            if len(lines) >= 3:
                print("found the nkmini.exe")
                break

    # 번개3 종료
    time.sleep(30)
    print("taskill nkmini.exe")
    os.system("taskkill /im nkmini.exe")
Beispiel #8
0
def test_sendpush(get_mock_happySleep):
    turn_on_autopush()
    app = Application().Start(cmd_line=u'C:\\Users\\login_test\\Desktop\\Release\\Release\\AuthUiTest.exe login_test')
    window = app.Dialog
    window.Wait('ready')

    time.sleep(10)

    contents = open('msgOutput.txt', 'r').readlines()
    return_code = int(contents[0].strip())
    print return_code

    content_lines = len(contents)
    if content_lines == 1:
        return_code = int(contents[0].strip())
        assert return_code == 1
    elif content_lines:
        return_code = int(contents[0].strip())
        return_msg = contents[1].strip()
        print return_code, return_msg
        assert return_code != 1

    app.Kill_()
Beispiel #9
0
def run_si_backup():
    print "Stock Investor Pro Automated Backup\n"

    # set paths
    si_path = "C:\Program Files (x86)\Stock Investor\Professional"
    os.chdir(si_path)

    backup_folder = "C:\Program Files (x86)\Stock Investor\Backups\\"
    pywinauto_typeable_backup_folder_name = "C:\Program{SPACE}Files{SPACE}{(}x86{)}\Stock{SPACE}Investor\Backups\\"
    if not os.path.exists(backup_folder):
        os.makedirs(backup_folder)

    current_day = datetime.datetime.today().strftime('%Y-%m-%d')
    todays_backup_folder = backup_folder + current_day + "\\"
    pywinauto_typeable_todays_backup_folder = pywinauto_typeable_backup_folder_name + current_day
    if not os.path.exists(todays_backup_folder):
        os.makedirs(todays_backup_folder)

    # Launch Stock Investor Pro
    app = Application().Start(si_path + "\si_util.exe")
    siutilc = app.si_util9c000000
    siutilc.Wait('ready')
    siutilc.SetFocus()

    for i in range(3):
        siutilc.TypeKeys("{TAB}")
        time.sleep(0.1)
    siutilc.TypeKeys("{ENTER}")
    time.sleep(0.1)
    siutilc.TypeKeys(pywinauto_typeable_todays_backup_folder)
    for i in range(2):
        siutilc.TypeKeys("{TAB}")
        time.sleep(0.1)
    siutilc.TypeKeys("{ENTER}")

    print "Backup created, exiting..."
    app.Kill_()
Beispiel #10
0
            button = dlg.OK
            button.Click()
            save_success = True
            break
        except:
            time.sleep(1)
    if not save_success:
        print "Error in saving file", str(
            save_id) + ".XLS, it took too long (5+ minutes)."
        print "\nExiting..."
        sys.exit()

# print success and open relevant folder, if set to do so
print "\nLooks like everything saved successfully."
print "Find your new data files at:", todays_save_folder
if open_save_folder:
    first_save_id_name_alphabetically = [x for x in sorted(save_id_list)][0]
    subprocess.Popen(r'explorer /select,' + todays_save_folder +
                     first_save_id_name_alphabetically.upper() + ".XLS")

print "All done, exiting..."
# Close SIpro
app.Kill_()
# play sound to indicate export was successful
sounds = [
    "Windows Unlock.wav", "notify.wav", "Windows Proximity Notification.wav",
    "Windows Exclamation.wav", "tada.wav"
]
sound = sounds[2]
winsound.PlaySound("C:\Windows\Media\\" + sound, winsound.SND_FILENAME)
Beispiel #11
0
    def treatgsinglecycle(self,treatgchannelpath):
        
        from_file=pathlib.Path(self.window.diff_tabs.resourcelocation+"TreatG2.exe")
        to_file=pathlib.Path(treatgchannelpath)
        shutil.copy(from_file,to_file)
        treatg_exe_place=pathlib.Path(to_file.joinpath("TreatG2.exe"))
        
        os.startfile(str(treatg_exe_place))
        
        old_path=pathlib.PureWindowsPath(treatg_exe_place)
        new_path=list(old_path.parts)
        var=[]
        for item in new_path:
            if len(item)>6:
                item=item[0:6]+"~"+"1"
                print(item)
                var.append(item)
        
    
            else:
                print(item)
                var.append(item)

        new_path="\\".join(var)+"\\TreatG2.exe"
        new_path=pathlib.PureWindowsPath(new_path)
        new_path=u"{}".format(str(new_path))
        
        
        app = Application().connect(title=new_path, class_name='ConsoleWindowClass')
        consolewindowclass = app.ConsoleWindowClass
        consolewindowclass.wait('ready')
        print("1")
        consolewindowclass.set_focus()
        #opening the popuplike box to show file names
        send_keys('{INS}')
        time.sleep(0.5)
        #selecting the first file
        send_keys('{RIGHT}{ENTER}')
        
        app.top_window().type_keys('{TAB}')
        
        time.sleep(0.5)
        app.top_window().type_keys('{TAB}')
        
        time.sleep(0.5)
        app.top_window().type_keys('{TAB}')
        
        time.sleep(0.5)
        send_keys('{DELETE}')
        time.sleep(0.5)
        send_keys("{2 down}"
                  "{2 up}"
                  "00.000"
                  ) # to type hello
        time.sleep(0.5)
        send_keys('{DOWN}')
        time.sleep(0.5)
        send_keys('{DELETE}')
        time.sleep(0.5)
        send_keys("{9 down}"
                  "{9 up}"
                  ".78335"
                  ) # to type hello
        
        
        send_keys('{ENTER}')
        time.sleep(1)
        send_keys('{ESC}')
        
        #to file is the treatgchannel path which is inside analysis_l1_L2+channel+treatgchannel
        tempfile=pathlib.Path(to_file.joinpath("RESULT.DAT"))
        result1path=pathlib.Path(to_file.joinpath("RESULT1.DAT"))
        #tempfile=pathlib.Path("D:/Auto/255678987/RESULT.DAT")
        #required=pathlib.Path("D:/Auto/255678987/RESULT1.DAT")
        shutil.copy(tempfile,result1path)
        
        
        app.top_window().type_keys('{TAB}')
        time.sleep(0.5)
        
        send_keys('{INS}')
        time.sleep(0.5)
        
        send_keys('{RIGHT}{RIGHT}{ENTER}')
        
        app.top_window().type_keys('{TAB}')
        time.sleep(0.5)
        send_keys('{DOWN}')
        time.sleep(0.5)
        send_keys('{SPACE}')
        
        app.top_window().type_keys('{TAB}')
        send_keys('{ENTER}')
        time.sleep(1)
        send_keys('{ESC}')
        
        tempfile=pathlib.Path(to_file.joinpath("RESULT.DAT"))
        result2path=pathlib.Path(to_file.joinpath("RESULT2.DAT"))
        #tempfile=pathlib.Path("D:/Auto/255678987/RESULT.DAT")
        #required=pathlib.Path("D:/Auto/255678987/RESULT2.DAT")
        shutil.copy(tempfile,result2path)
        
        
        
        app.top_window().type_keys('{TAB}')
        
        time.sleep(0.5)
        app.top_window().type_keys('{TAB}')
        time.sleep(0.5)
        send_keys('{INS}')
        time.sleep(0.5)
        send_keys('{RIGHT}')
        time.sleep(0.5)
        send_keys('{RIGHT}')
        
        time.sleep(0.5)
        send_keys('{RIGHT}{ENTER}')
        
        app.top_window().type_keys('{TAB}')
        
        time.sleep(0.5)
        app.top_window().type_keys('{TAB}')
        send_keys('{ENTER}')
        time.sleep(1)
        send_keys('{ESC}')
        tempfile=pathlib.Path(to_file.joinpath("RESULT.DAT"))
        result3path=pathlib.Path(to_file.joinpath("RESULT3.DAT"))
        shutil.copy(tempfile,result3path)
#        tempfile=pathlib.Path("D:/Auto/255678987/RESULT.DAT")
#        required=pathlib.Path("D:/Auto/255678987/RESULT3.DAT")
        
        #Now copy all the three files to the previous folder which is channelfolder
        shutil.copy(result1path,to_file.parent)
        shutil.copy(result2path,to_file.parent)
        shutil.copy(result3path,to_file.parent)
        
        
        app.Kill_()
Beispiel #12
0
def genera_fichero_csv_datos_vatimetro(
        fichero_datos_vati_lcr,
        planta=None,
        ruta_lmg_control='C:/Program Files (x86)/LMG-CONTROL/',
        fichero_inacabado=False):
    """
    Genera el fichero .csv dado un fichero .lcr usando el programa del vatímetro LMG Control
     * Toma como path por defecto el de donde esta el script
     * Lee .lcr del servidor si no existe o fuerza_descarga=True
     * Sobreescribe si el fichero ya está creado
     
     NOTA: usa LMG-Control v2.36
            - Requiere instalar 'pywinauto' mediante 'pip install pywinauto'

    Parameters
    ----------


    Returns
    -------


    See Also
    --------

    Examples
    --------
    >>> 
    """
    import pywinauto
    from pywinauto.application import Application

    print('No tocar el teclado y el ratón durante la ejecución!')

    if planta == 'intrepid':
        path_local = PATH_VATIMETRO_INTREPID
    elif planta == 'fadrique':
        path_local = PATH_VATIMETRO_FADRIQUE
    else:
        raise Exception(
            'Hay que indicar un tipo de planta correto: "intrepid", "fadrique"'
        )

    ruta_fichero_lcr = os.path.join(os.path.normpath(path_local),
                                    fichero_datos_vati_lcr)
    ruta_fichero_csv = os.path.join(os.path.normpath(path_local),
                                    fichero_datos_vati_lcr[:-3] + 'csv')

    app = Application().start(
        ruta_lmg_control + 'lmgcontrol.exe' + ' ' + '"' + ruta_fichero_lcr +
        '"'
    )  # windows requiere que esté entre "" por los espacios en los nombres

    # fichero_inacadado porque aun está leyendo
    if fichero_inacabado:
        # dialogo de fichero inacabado, hace click en 'Sí'
        window1 = app.Dialog
        window1.Wait('ready', timeout=30)
        window1['&Sí'].Click()

    # entra en menu 'File' y va a Exportar
    wxwindowclassnr = app.wxWindowClassNR
    wxwindowclassnr.Wait('ready')
    wxwindowclassnr.MenuItem('File->Export recording').Click()

    # Va a menu Guardar
    window2 = app['Export']
    window2.Wait('ready')
    window2['Export'].Click()

    # escribe ruta y nombre fichero .csv
    window3 = app.Dialog
    window3.Wait('ready')
    combobox = window3['4']
    combobox.TypeKeys(ruta_fichero_csv, with_spaces=True)

    # clicka 'Guardar'
    window4 = app.Dialog
    window4.Wait('ready')
    window4.Button.Click()

    # Si aparece el diálogo de 'Confirmar Guardar como' porque el fichero ya existe, lo sobreescribe
    if len(pywinauto.findwindows.find_windows(
            title='Confirmar Guardar como')) != 0:
        window_conf = app.Dialog
        window_conf.Wait('ready')
        window_conf['&Sí'].Click()

    # Espera a que aparezca el botón 'Close'
    while True:
        try:
            window5 = app.Dialog
            window5.Wait('ready')
            window5['Close'].Click()
            break
        except Exception:
            print('Aun no ha aparecido el botón de "Close"')

    # Mata el proceso
    app.Kill_()

    print('Fichero .csv generado')