Aelc Posted March 18, 2022 Share Posted March 18, 2022 Hey there! i'm struggling a bit while trying to get the Output out of the python console Quote #include <Constants.au3> Local $pid = Run("C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python39_64\python.exe myscript.py","",@SW_SHOW,$STDOUT_CHILD + $STDERR_CHILD) $var = "" While ProcessExists($pid) $var &= StderrRead($pid) $var &= StdoutRead($pid) If @error Then ExitLoop ConsoleWrite(@crlf & $var & @CRLF) WEnd MsgBox(64, 'Result', $var) the funny thing is the stderrread is working ... any suggestions? why do i get garbage when i buy garbage bags? Link to comment Share on other sites More sharing options...
Developers Jos Posted March 18, 2022 Developers Share Posted March 18, 2022 Moved to the appropriate AutoIt General Help and Support forum, as the Developer General Discussion forum very clearly states: Quote General development and scripting discussions. Do not create AutoIt-related topics here, use the AutoIt General Help and Support or AutoIt Technical Discussion forums. Moderation Team SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Aelc Posted March 18, 2022 Author Share Posted March 18, 2022 (edited) sorry @Jos im to stupid to read - to tired Edited March 18, 2022 by Aelc why do i get garbage when i buy garbage bags? Link to comment Share on other sites More sharing options...
Gianni Posted March 18, 2022 Share Posted March 18, 2022 5 hours ago, Aelc said: any suggestions? you can try to use $STDERR_MERGED instead of $STDOUT_CHILD + $STDERR_CHILD and then read the stream using only one $var &= StdoutRead($pid) Aelc 1 Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt.... Link to comment Share on other sites More sharing options...
Aelc Posted March 18, 2022 Author Share Posted March 18, 2022 Tried it quickly and seems to work. The consolewrite() still only outputs the std_error and not the printouts from Python... but I'll take a deeper look laterThanks so far! why do i get garbage when i buy garbage bags? Link to comment Share on other sites More sharing options...
Danp2 Posted March 18, 2022 Share Posted March 18, 2022 Do you get the expected output if you run your Python script directly from the console? Also, can you show us the Python script? Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
Aelc Posted March 23, 2022 Author Share Posted March 23, 2022 @Danp2 sorry was busy in other projects When i start the script with visual studio it works as expected. The output is shown in the console. Well the prob is i attach a website with selenium and login. So you wont be able to take a deeper look into it, but it's not neccessary i guess. Actually i want to know how it works with basic scripts. Thats my main script: expandcollapse popupfrom selenium import webdriver from selenium.webdriver.chrome.service import Service from selenium.webdriver.common import options, service from selenium.webdriver.common.by import By from selenium.common.exceptions import NoSuchElementException from selenium import webdriver import os from time import sleep from datetime import datetime from datetime import date from Passport import User, Pass from classes import Button, Sidebar, Label, EndTime, StartTime, Chromedriver ####################################################### ***** GetTime ***** ##################################################### def GetTime(ret): now = datetime.now() if ret == "H": return int(now.strftime("%H")) elif ret == "M": return int(now.strftime("%M")) elif ret == "HM": return now.strftime("%H:%M") ####################################################### ***** GetinnerHTML ***** ##################################################### def GetinnerHTML(obj): if type(obj) is bool: return "" else: return obj.get_attribute("innerHTML") ####################################################### ***** GetElement ***** ####################################################### def GetElement(sSearch,sName,ShowDebug=True): try: elem = driver.find_element(sSearch,sName) return elem except NoSuchElementException: if ShowDebug: print ('Element"' + sName + '" nicht gefunden') Sleep(1) return False ########################################################## ***** Sleep ***** ######################################################### def Sleep(duration): import time time.sleep(duration) return ######################################################### ***** LogIN_OUT ***** ###################################################### def LogIN_OUT (elemXpath,innerHTMLtoCheck = "Starten", Executelink = Chromedriver.Options.LoginLink, reloadDefaultWebsite = True): print("********* " + innerHTMLtoCheck + "... *********") print("********* Try *********") try: Login_out = GetElement(By.XPATH,elemXpath) if (Login_out) != False: LoginHTML = GetinnerHTML(Login_out) if (LoginHTML) == innerHTMLtoCheck: Login_out.click() print("********* " + innerHTMLtoCheck + " failed... try to work around *********") return Login_out except NoSuchElementException: SideBarL = GetElement(Sidebar.search,Sidebar.name) if SideBarL.get_property("aria-expanded") == "false": driver.get(Executelink) if reloadDefaultWebsite == True: driver.get(Chromedriver.Options.DefaultLink) print("------------------ Except ------------------") print("------------------ Except ------------------") print("------------------ Except ------------------") ######################################################### ***** Double Print ***** ##################################################### def DblePrint(TXT): print ("") print (TXT) ######################################################### ***** StartupChrome ***** ##################################################### def StartChrome(link): chrome_options = webdriver.ChromeOptions() #chrome_options.add_argument('headless') chrome_options.add_argument('window-size=' + Chromedriver.Options.size) chrome_options.add_argument('--disable-default-apps') chrome_options.add_argument('user-data-dir=C:\\Users\\' + User._dir + '\\Desktop\\CHROME\\User data') global driver driver = webdriver.Chrome(Chromedriver.path, options=chrome_options) driver.get(Chromedriver.Options.DefaultLink) driver.set_page_load_timeout(25) StartChrome(Chromedriver.Options.DefaultLink) openZoom = True # Mainloop while driver: # Check URL if driver.current_url != Chromedriver.Options.DefaultLink: driver.get(Chromedriver.Options.DefaultLink) # Try extend login session ExtendButton = GetElement(By.XPATH,Button.MainPage.name,False) if ExtendButton: if ExtendButton.get_attribute("data-action") == "save": ExtendButton.click() # Get LoginElements SideBarL = GetElement(Sidebar.search,Sidebar.name) if SideBarL == False: Use = GetElement(User.search,User.name) Pas = GetElement(Pass.search,Pass.name) Btn = GetElement(By.XPATH,Button.MainPage.name) # Send Keys if (Use) != False and (Pas) != False and (Btn) != False: Use.send_keys(User.write) Pas.send_keys(Pass.write) if GetinnerHTML(Btn) == "Login": Btn.click() DblePrint("********* Login... *********") # set int for loop i = 0 # timeout website driver.set_page_load_timeout(25) # loop it! while i < 1: # Get Label Lab = GetElement(By.XPATH, Label.name,False) # Get Label Txt Label_TXT = GetinnerHTML(Lab) # long sleep if GetTime("H") != StartTime.h and GetTime ("H") != EndTime.h: DblePrint ("********* long sleep *********") print ("********* long sleep *********") print ("********* long sleep *********") Sle = 120 driver.get(Chromedriver.Options.DefaultLink) while Sle > 1: Sleep (1) Sle -= 1 print ("********* " + str(Sle) + " seconds *********") if Label_TXT == "Achtung Zeiterfassung starten!": break if Label_TXT == "Heute kein Unterricht!": DblePrint ("********* Sleep -> " + GetTime("HM") + " *********") Sleep(15) else: break DblePrint ("********* current time " + GetTime("HM") + " *********") Sleep (1) # "time start" if GetTime("H") == StartTime.h and GetTime("M") >= StartTime.m: print ("********* start time " + StartTime.hstr + ":" + StartTime.mstr + " *********") LogIN_OUT (Button.MainPage.name,"Starten",Chromedriver.Options.LoginLink,True) cards = driver.find_elements(By.XPATH,"//div[@class='card']") if openZoom == True: openZoom = False print ( '------------------------------------ Get "cards" ----------------------------------------------') result = driver.find_element(By.XPATH,"//div[@class='card']") for i in cards: CardsRaw = i.find_element(By.XPATH,".//h4[@class='card-title']/a") check = GetinnerHTML(CardsRaw) print (check) Startdate = check[-21:-11].split(".") Enddate = check[-10:].split(".") today = datetime.today() if(isinstance(Startdate,list) and isinstance(Enddate,list)): if Startdate[0].isdigit() and Startdate[1].isdigit() and Startdate[2].isdigit() and Enddate[0].isdigit() and Enddate[1].isdigit() and Enddate[2].isdigit() and len(Startdate) == 3 and len(Enddate) == 3: if ((today.day >= int(Startdate[0]) and today.day <= int(Enddate[0])) and (today.month == int(Startdate[1]) or today.month == int(Enddate[1])) and (today.year == int(Startdate[2]) or today.year == int(Enddate[2]))): print ( '------------------------------------ match found ----------------------------------------------') DblePrint (check) result = CardsRaw CardsRaw.click() driver.set_page_load_timeout(25) ZoomLink = driver.find_element(by=By.CLASS_NAME,value="zoom") DblePrint ('------------------------------------ found zoomlink ----------------------------------------------') if ZoomLink: ZoomLink.click() driver.set_page_load_timeout(25) Meeting = GetElement(By.XPATH,"//form[@target='_blank']") if(GetElement(By.XPATH,Button.MainPage.name)): driver.execute_script("arguments[0].setAttribute('target',arguments[1])",Meeting, "_self") Meet = GetElement(By.XPATH,Button.MainPage.name) if Meet: DblePrint ('------------------------------------ meeting avaible ----------------------------------------------') Meet.click() driver.set_page_load_timeout(25) lastone = GetElement(By.XPATH,"//div[@role='button']") if lastone: DblePrint ('------------------------------------ join ----------------------------------------------') lastone.click() driver.set_page_load_timeout(25) Sleep (2) break # "time end" if GetTime("H") == EndTime.h and GetTime("M") >= EndTime.m: print ("********* end time " + EndTime.hstr + ":" + EndTime.mstr + " *********") LogIN_OUT (Button.MainPage.name,"Beenden",Chromedriver.Options.LogoutLink,True) # quit driver driver.quit() You will need the classes.py aswell from os import name from selenium.webdriver.common.by import By from datetime import datetime from time import sleep class Chromedriver: path = '/chromedriver' class Options: size = "1920,1080" DefaultLink = "https://lernplattform.gfn.de/" LoginLink = DefaultLink + "?starten=1" LogoutLink = DefaultLink + "?stoppen=1" class Button: class MainPage: name = '//button[@class="btn btn-primary"]' search = By.XPATH class Label: name = '//div[@class="alert alert-warning"]' search = By.XPATH class EndTime: h = 16 m = 33 hstr = str(h) mstr = str(m) class StartTime: h = 8 m = 25 hstr = str(h) mstr = str(m) class Sidebar: name = "sidepreopen-control" search = By.ID and i stored the login in the passport.py (normally stored in a JSON) from selenium.webdriver.common.by import By class User: name = "username" search = By.ID write = "***MY-EMAIL***" _dir = "***MY-USERDIR***" class Pass: name = "password" search = By.ID write = "***MY-PASSWORD***" btw my first python project - im trying to learn i will show you the output aswell - is maybe easier to understand - instead to change the other inputs without any account to access. All it does is to press a button while logged in when the time has come and go the right course - starting zoom meeting. But does this matter? i would say no 😜 Greetings why do i get garbage when i buy garbage bags? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now