Pyinstaller fails to make my file executable - python

I have a gspread python file that writes into sheets.
it works when I run it but when Im trying to convert it into an .exe file using pyinstaller moudule with the command: pyinstaller -F main.py it builds the file successfully. becuse I have some dependencies I move the main.exe out from the dist folder to the project folder where all the dependencies are.
When Im trying to run the main.exe file the cmd window opens and prints this without stopping:
Cannot listen to an undefined element. [Caught in: Tried to listen to element of type click]
Subsequent non-fatal errors won't be logged; see https://fburl.com/debugjs.", source: https://static.xx.fbcdn.net/rsrc.php/v3/yi/r/wTY5qBMkTkR.js?_nc_x=Ij3Wp8lg5Kz (58)
[0219/203902.470:INFO:CONSOLE(13)] "Date was set (cloudfront.js)", source: https://s3-eu-west-1.amazonaws.com/secure-konimbo/public/data/cloudfront/javascripts/cloudfront.js?v=1645294790 (13)
[0219/203902.504:INFO:CONSOLE(22)] "cloudfront.js v35 (document - ready)", source: https://s3-eu-west-1.amazonaws.com/secure-konimbo/public/data/cloudfront/javascripts/cloudfront.js?v=1645294790 (22)
[0219/203902.521:INFO:CONSOLE(13594)] "margin-top 62", source: https://www.myperfume.co.il/155569-%D7%9B%D7%9C-%D7%94%D7%9E%D7%95%D7%AA%D7%92%D7%99%D7%9D-%D7%9C%D7%90%D7%99%D7%A9%D7%94?order=up_title&page=3 (13594)
[0219/203902.525:INFO:CONSOLE(13594)] "right 0", source: https://www.myperfume.co.il/155569-%D7%9B%D7%9C-%D7%94%D7%9E%D7%95%D7%AA%D7%92%D7%99%D7%9D-%D7%9C%D7%90%D7%99%D7%A9%D7%94?order=up_title&page=3 (13594)
[0219/203902.525:INFO:CONSOLE(13594)] "left auto", source: https://www.myperfume.co.il/155569-%D7%9B%D7%9C-%D7%94%D7%9E%D7%95%D7%AA%D7%92%D7%99%D7%9D-%D7%9C%D7%90%D7%99%D7%A9%D7%94?order=up_title&page=3 (13594)
[0219/203902.553:INFO:CONSOLE(1)] "%c[IND]%c You are running %cWindows%c Operating system, %cChrome%c browser, version: %c98 color: White; background: #17384c; font-weight: bold; padding: 3px; border-radius:3px 0 0 3px; color: Black; background: #50e590; font-weight: bold; padding: 3px color: White; background: #17384c; font-weight: bold; padding: 3px; color: Black; background: #50e590; font-weight: bold; padding: 3px color: White; background: #17384c; font-weight: bold; padding: 3px; color: Black; background: #50e590; font-weight: bold; padding: 3px color: White; background: #17384c; font-weight: bold; padding: 3px; border-radius:0 3px 3px 0", source: https://js.nagich.co.il/core/3.0.0/accessibility.js (1)
[0219/203902.553:INFO:CONSOLE(1)] "%c[IND]%c Version %c3.0.0%c color: White; background: #17384c; font-weight: bold; padding: 3px; border-radius:3px 0 0 3px; color: Black; background: #50e590; font-weight: bold; padding: 3px color: White; background: #17384c; font-weight: bold; padding: 3px; border-radius:0 3px 3px 0 ", source: https://js.nagich.co.il/core/3.0.0/accessibility.js (1)
Does anyone knows how to deal with this?(I thinks it has something to do with the oauoth2client library)

Related

Copying hyperlinked text to the clipboard in Python pyperclip3

My program needs to copy into the clipboard some text with hyhperlinks, so that the user can later paste the text (with hyperlinks) into an app (e.g. Word, Slack).
This functionality works in most apps: for example if I copy a piece of text from a browser (or a Word doc, or a Slack message) which contains hyperlinks, when I paste it into another app it preserves the links.
However when I paste this content with pyperclip I only recover the text (there are no hyperlinks).
After some research I think I need to use a binary form of paperclip content, via pyperclip3. But I don't know how to construct the hyperlinked string object.
When I pyperclip3.paste() after copying the string from Word, I obtain what looks like a binary PDF object. Perhaps I need to create a binary PDF with the link and pass it to pyperclip3.copy()? Are there easier ways? Perhaps MIME?
Not sure if it is possible, but it's going to be very hard to use pyperclip to get hyperlinks, maybe even impossible. A possible option is to use Beautiful Soup and richxerox using Mac environment:
from richxerox import *
from bs4 import BeautifulSoup
soup = BeautifulSoup(pasteboard.get_contents(format='html'),'lxml')
links = [i.attrs['href'] for i in soup.find_all('a')]
print(links)
When copying to the clipboard in Windows, the application can choose to make several formats of the data available to an application that wishes to paste the data. I have attached a screenshot of the different formats available when copying from Chrome.
I know PySide6, a Python wrapper around Qt, lets you give the mime-type of the data you are putting into the clipboard. I don't know if there is a similar feature in pyperclip. This feature lets you share html with included hyperlinks directly with another application.
app.clipboard().mimeData().setHtml("""<html>
<body>
<!--StartFragment--><h3 class="s-post-summary--content-title" style="margin: -0.15rem 0px 0.3846rem; padding-top: 0px; padding-right: var(--su24); padding-bottom: 0px; padding-left: 0px; border: 0px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-variant-numeric: inherit; font-variant-east-asian: inherit; font-weight: 400; font-stretch: inherit; line-height: var(--lh-md); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI Adjusted", "Segoe UI", "Liberation Sans", sans-serif; font-size: var(--fs-body3); vertical-align: baseline; box-sizing: inherit; display: block; word-break: break-word !important; overflow-wrap: break-word !important; hyphens: auto !important; color: rgb(35, 38, 41); letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">
Copying hyperlinked text to the clipboard in Python pyperclip3</h3><div class="s-post-summary--content-excerpt" style="margin-top: calc(var(--su2) * -1); margin-right: 0px; margin-bottom: var(--su8); margin-left: 0px; padding: 0px; border: 0px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-variant-numeric: inherit; font-variant-east-asian: inherit; font-weight: 400; font-stretch: inherit; line-height: inherit; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI Adjusted", "Segoe UI", "Liberation Sans", sans-serif; font-size: 13px; vertical-align: baseline; box-sizing: inherit; color: var(--fc-medium); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; word-break: break-word !important; overflow-wrap: break-word !important; hyphens: auto !important; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">
My program needs to copy into the clipboard some text with hyhperlinks, so that the user</div><!--EndFragment-->
</body>
</html>
""")
Update: Pyperclip "Currently only handles plaintext." So copying hyperlinks isn't an option currently with pyperclip. https://github.com/asweigart/pyperclip#:~:text=Currently%20only%20handles%20plaintext.

PyGObject, Gtk.Entry height has a minimum?

I cannot get the Gtk.Entry's height smaller than in this picture. I have made the text very small and tried setting CSS styles for padding and border. The padding at 10px makes the entry even bigger and at 0px is the same as not adding the padding tag. You can see that the Gtk.Label is using the same size font and it is much smaller. Using PyGObject with Gtk3. Any ideas?
.settings_label {
color: white;
font-size: 6px;
font-weight: bold;
}
.settings_entry {
color: white;
font-size: 6px;
padding: 0px;
border: 1px;
}

How to find element by long complicated xpath?

I want to find a button, but don't know how as the html code is complicated. Can you help me?
HTML
<div style="margin-top: 20px;">
<span style="display: inline-block; margin: 5px; padding: 10px 15px; border-radius: 5px; font-size: 18px; line-height: 16px; cursor: pointer; color: rgb(255, 255, 255); background-color: rgb(99, 99, 102);">Bugsnag akzeptieren
</span>
<span style="display: inline-block; margin: 5px; padding: 10px 15px; border-radius: 5px; font-size: 18px; line-height: 16px; cursor: pointer; color: rgb(255, 255, 255); background-color: rgb(0, 122, 255);">Alle akzeptieren
</span>
</div>
So I want to find the second element and tried things like:
self.browser.find_elements_by_xpath("//span[#style='the whole text that equals style in the html']")
But it does not seem to work...
Depending on what you would like to do with it, you could do //span[2] to select the second span:
Example of Selecting Element
self.browser.find_elements_by_xpath("//span[2]")
if you want the entire element.
Example of Selecting Text
self.browser.find_elements_by_xpath("//span[2]/text()")
if you want the inner html text of the second span.
I tested the xpath expression on this website to make sure that it works.
I copied in the html you provided and just entered the xpath expression //span[2]/text() to test it.
More info on xpath here.

Capture a code block into a string variable in python

I want to dynamically create an html code block but I'm not sure how to assign this into a variable:
<head>
<style>
body {
border-style: solid;
border-width: 5px;
border-color: green;
border-radius: 5px;
border-spacing: 30px;
background-color: #FFFFC2;
padding-bottom: 5px;
font-size: 25px;
}
li {
color: #F7270F;
font-weight: bold;
}
</style>
</head>
<body>
<div style="margin-bottom: 5px; margin-top: 5px; margin-left: 10px; margin-right: 10px;">
<h1 align="center">Auctions for Week of 08-01-2018</h1>
<p>You are bidding on the following item:</p>
<ul><li>This is the item for sale</li></ul>
<p>Condition is pack fresh unless otherwise indicated. Please review the pictures carefully and if you have any questions about something specific, ask.</p>
<p><b>Shipping:</b> Shipping will be calculated based on buyer location. No premiums are charged. Cards are mailed in an 8x5 bubble mailer and shipped First Class mail unless the price exceeds $50, at which point they will be shipped Priority at no additional cost to the buyer. If you win multiple auctions, please wait for an invoice to be sent.</p>
</div>
</body>
I've tried executing:
html_desc="<code_block>"
but it doesn't like the way that works... so I'm a bit stumped. The reason I'm trying to put this into a variable is because I need to make this a key value for a JSON statement.
You can put that code block inside triple quotes """ (I put the variable inside json.dumps, just for example):
from pprint import pprint
import json
html_desc = """<head>
<style>
body {
border-style: solid;
border-width: 5px;
border-color: green;
border-radius: 5px;
border-spacing: 30px;
background-color: #FFFFC2;
padding-bottom: 5px;
font-size: 25px;
}
li {
color: #F7270F;
font-weight: bold;
}
</style>
</head>
<body>
<div style="margin-bottom: 5px; margin-top: 5px; margin-left: 10px; margin-right: 10px;">
<h1 align="center">Auctions for Week of 08-01-2018</h1>
<p>You are bidding on the following item:</p>
<ul><li>This is the item for sale</li></ul>
<p>Condition is pack fresh unless otherwise indicated. Please review the pictures carefully and if you have any questions about something specific, ask.</p>
<p><b>Shipping:</b> Shipping will be calculated based on buyer location. No premiums are charged. Cards are mailed in an 8x5 bubble mailer and shipped First Class mail unless the price exceeds $50, at which point they will be shipped Priority at no additional cost to the buyer. If you win multiple auctions, please wait for an invoice to be sent.</p>
</div>
</body>"""
pprint(json.dumps({html_desc: "Some Value"}))

How can I change/remove style attibute with selenium python?

I was wondering if it was possible to change or remove the "display: none;" in the element to make it visible with selenium in python.
<textarea id="g-recaptcha-response" name="g-recaptcha-response" class="g-recaptcha-response" style="width: 250px; height: 40px; border: 1px solid #c1c1c1; margin: 10px 25px; padding: 0px; resize: none; display: none; "></textarea>
I already tried this:
driver.execute_script("document.getElementById('g-recaptcha-response').style.display = '1';")
but apparently it does not work.
Any help would be apprreciated. :)
It was just the wrong CSS attribute, this works
driver.execute_script("document.getElementById('g-recaptcha-response').style.display = 'block';")
Thanks to #Andersson

Categories