python-2.7

Creating Executable File For Python 2.7

懵懂的女人 提交于 2021-02-08 06:53:25
问题 I want to make an executable file from a python file the python file is written for Python 2.7. I tried pyinstaller but it gives me an error when installing. I'm guessing it does not have support for Python 2.7 anymore. Are there any alternatives for pyinstaller that work with Python 2.7? I tried installing cx_Freeze version 5.1.1 but it gives me the following error: Cleaning up... Command C:\Python27\python.exe -c "import setuptools, tokenize;__file__='c:\\users\\win-10\\appdata\\local\\temp

how to stop one process from another in Python

筅森魡賤 提交于 2021-02-08 06:50:54
问题 On a Raspberry Pi I'm running two processes which loop constantly until an input is triggered which stops one of the processes but how do I stop both processes? The only thing that works is pressing control+c in the console I can't get it to stop with code at this moment. def stopButton(): while 1: wiringpi2.pinMode(52,0) stopBut = wiringpi2.digitalRead(52) print (stopBut) wiringpi2.delay(500) if (stopBut == 0): stopBlink() def stopBlink(): redBlink = int(0) while (redBlink < int(20)):

Google scrapping using python - requests: How to avoid being blocked due to many requests?

偶尔善良 提交于 2021-02-08 06:37:33
问题 For a school project I need get the web addresses of 200 companies (based on a list). My script is working fine, but when I'm around the company 80, I get blocked by google. This is the message that I'm getting. > Our systems have detected unusual traffic from your computer network. > This page checks to see if it's really you sending the requests, and > not a robot. <a href="#" > onclick="document.getElementById('infoDiv').style.display='block' I tried two different ways to get my data: A

PyQt4 - how to add scrollbar into tabbed windows of fixed size?

旧巷老猫 提交于 2021-02-08 06:34:51
问题 Simplest case: How do you add a scrollbar to a tabbed GUI window of fixed size? Full case: I'm working with a GUI with non-scaleable objects (scenes) in each tabbed frame, and would like the user to still be able to drag-scale the window down on itself (whereby the objects in the scene don't scale, but just get hidden as the window-drag moves over them) and a scroll bar appears. This is the minimal, working code that I've written to help exemplify: import sys from pyface.qt import QtGui,

How to clear cmd/terminal while running a python script

╄→尐↘猪︶ㄣ 提交于 2021-02-08 05:36:18
问题 I keep seeing ways to clear the shell while running a script, however is there a way to clear the screen while running a script in the CMD? My current method works like this: clear.py import title def clear(): print('\n' * 25) title.title() game.py from engine import clear clear.clear() print(Fore.CYAN + Style.BRIGHT + "--------------------------------") However this method isn't really reliable as some cmd sizes are different on all computers, nor have I tried it on OSx. 回答1: Here's another

Consolidating two dictionaries with the same keys and different values

≯℡__Kan透↙ 提交于 2021-02-08 05:23:37
问题 I have two collection.Counter()s, both of which of the same keys, so they look something like this: 01: 3 02: 2 03: 4 01: 8 02: 10 03: 13 I want the final result to look a bit more like this: 01: [3, 8] 02: [2, 10] 03: [4, 13] How would I go about merging them? 回答1: You can use a dict comprehension: dict1 = {1: 3, 2: 2, 3: 4 } dict2 = {1: 8, 2: 10, 3: 13 } dict3 = { k: [ dict1[k], dict2[k] ] for k in dict1 } # Result: # dict3 = {1: [3, 8], 2: [2, 10], 3: [4, 13]} 回答2: There aren't any

Consolidating two dictionaries with the same keys and different values

狂风中的少年 提交于 2021-02-08 05:23:07
问题 I have two collection.Counter()s, both of which of the same keys, so they look something like this: 01: 3 02: 2 03: 4 01: 8 02: 10 03: 13 I want the final result to look a bit more like this: 01: [3, 8] 02: [2, 10] 03: [4, 13] How would I go about merging them? 回答1: You can use a dict comprehension: dict1 = {1: 3, 2: 2, 3: 4 } dict2 = {1: 8, 2: 10, 3: 13 } dict3 = { k: [ dict1[k], dict2[k] ] for k in dict1 } # Result: # dict3 = {1: [3, 8], 2: [2, 10], 3: [4, 13]} 回答2: There aren't any

How do I include screenshot in python pytest html report

我的未来我决定 提交于 2021-02-08 05:17:45
问题 When I hit the below url in browser "https://192.168.xx.xxx/Test/ScreenCapture" I get the screenshot of the device screen under test in the browser. How do I add the screenshot in my pytest html test report. Currently I am using below code which captures screen shot in the test directory specified. url = 'https://192.168.xx.xxx/Test/ScreenCapture' driver.get(url) driver.save_screenshot('/home/tests/screen.png') I am running my pytest with below command : py.test --html=report.html --self

Kivy Get Position of Widget in Scatter while moving it

久未见 提交于 2021-02-08 05:17:05
问题 I searched a lot for it bit i didn't find a solution. I would like to grab a widget in a kivy scatter and get the position of it each time i move it. So it could like so: def onmove_in_scatter(args): x = args[0] y = args[1] print("You are currently here: "+str(x)+":"+str(y)) It's important that the function is called WHILE i move the widget. 回答1: When I want to do something like this I override the on_touch_move. Here is a full* working example. (just put a cat.png somewhere...) import kivy

Kivy Get Position of Widget in Scatter while moving it

跟風遠走 提交于 2021-02-08 05:15:39
问题 I searched a lot for it bit i didn't find a solution. I would like to grab a widget in a kivy scatter and get the position of it each time i move it. So it could like so: def onmove_in_scatter(args): x = args[0] y = args[1] print("You are currently here: "+str(x)+":"+str(y)) It's important that the function is called WHILE i move the widget. 回答1: When I want to do something like this I override the on_touch_move. Here is a full* working example. (just put a cat.png somewhere...) import kivy