Mi hermano es el programador y le pedí ayuda para un programa, lógicamente me ayudó mucho y ahora estoy en una encrucijada... Específico: Hicimos este pequeño archivo y lo compilamos en 64 bits... Entiendo que en sistemas de 32b no funcione, pero no tiene por que fallar en un sistema de 64bits y demás... A alguien se le ocurre que falla? no da error en sistemas de 64b, sencillamente en el proceso indicado no llega a señalar 10/10 sino que se queda clavado en 2/10, ya lo veréis en el script, gracias de antemano!
Porcierto: He intentado ejecutar el .exe en máquinas de 64bits con windows 8 (como la mía) sin que activen el antivirus ni el firewall (nose, por si acaso) y nada, he pedido que instalen VLC player, por el tema de las conexiones y nada... No se que mas hacer!
Cita:
from PyQt4 import QtGui
from PyQt4.QtCore import pyqtSignal
from PyQt4.QtCore import *
import urllib2
import subprocess
import json
import sys
import threading
import time
from Queue import Queue
import collections
###################
channel_name = 'gatoluxo93'
###################
nombre_de_canal = ''
numberOfViewers = 10
builderThreads = 2
startTime = time.time()
numberOfSockets = 0
concurrent = 11
urls = []
urlsUsed = []
working = False
closed = False
class TwitchViewers():
def __init__(self, gui):
self.gui = gui
def getURL(self, nview): # Get tokens
global nombre_de_canal
output = subprocess.Popen([
"livestreamer",
"twitch.tv/"+nombre_de_canal,
"-j",
"--crunchyroll-purge-credentials"
], stdout=subprocess.PIPE,stdin=subprocess.PIPE,stder r=subprocess.PIPE, creationflags=0x08000000).communicate()[0]
# print json.loads(output)
# print output
try:
return json.loads(output)['streams']['worst']['url'] # Parse json and return the URL parameter
except Exception, e:
# print 'error get ', e, json.loads(output)
try:
if json.loads(output)['error'].find('No streams') != -1:
self.gui.trigger.emit()
except:
pass
def build(self): # Builds a set of tokens, aka viewers
global numberOfSockets
global numberOfViewers
global closed
global working
while True:
if closed:
break
# print 'si si ' + str(working) +" "+ str(closed)
if working and numberOfSockets < numberOfViewers:
numberOfSockets += 1
# print "Building viewers " + str(numberOfSockets) + "/" + str(numberOfViewers)
self.gui.setViewers(numberOfSockets)
url = self.getURL(numberOfSockets)
if url:
urls.append(url)
time.sleep(1)
def view(self): # Opens connections to send views
global numberOfSockets
global closed
while True:
if closed:
break
url=self.queue.get()
try:
request = urllib2.Request(url)
request.get_method = lambda : 'HEAD'
response = urllib2.urlopen(request).read()
except:
# print 'error view'
self.gui.trigger.emit()
if (url in urlsUsed):
urls.remove(url)
urlsUsed.remove(url)
numberOfSockets -= 1
else:
urlsUsed.append(url)
self.queue.task_done()
def run(self):
global closed
global working
for i in range(0, builderThreads):
threading.Thread(target = self.build).start()
self.queue=Queue(concurrent*2)
for i in range(concurrent):
try:
t=threading.Thread(target=self.view)
t.daemon=True
t.start()
except Exception, e:
pass
# print 'thread error ', e
while True:
if closed:
break
if working:
while (numberOfViewers != numberOfSockets): # Wait until sockets are built
if closed:
break
time.sleep(1)
try:
for url in urls:
# print url
self.queue.put(url.strip())
self.queue.join()
except KeyboardInterrupt:
sys.exit(1)
time.sleep(1)
class TwitchViewersGui(QtGui.QWidget):
trigger = pyqtSignal()
def __init__(self, parent=None):
super(TwitchViewersGui, self).__init__(parent)
helloLabel = QtGui.QLabel("Channel name")
self.helloLineEdit = QtGui.QLineEdit(channel_name)
self.helloLineEdit.setReadOnly(True)
self.button = QtGui.QPushButton('Start', self)
self.button.clicked.connect(self.handleButton)
self.started = False
self.infoLabel = QtGui.QLabel()
self.infoLabel.setStyleSheet("QLabel { color : green;}");
mainLayout = QtGui.QGridLayout()
mainLayout.addWidget(helloLabel, 0, 0)
mainLayout.addWidget(self.helloLineEdit, 0, 1)
mainLayout.addWidget(self.button, 1, 0)
mainLayout.addWidget(self.infoLabel, 1, 1)
self.setLayout(mainLayout)
self.setWindowTitle("+10 Twitch Viewers")
self.trigger.connect(self.errorStop)
def handleButton(self):
global working
global nombre_de_canal
global numberOfSockets
global urls
global urlsUsed
nombre_de_canal = str(self.helloLineEdit.text())
if nombre_de_canal:
numberOfSockets = 0
urls = []
urlsUsed = []
self.started = not self.started
working = self.started
self.infoLabel.setStyleSheet("QLabel { color : green;}");
self.infoLabel.setText('')
self.button.setText('Stop' if self.started else 'Start')
self.helloLineEdit.setStyleSheet("QLineEdit { background-color : "+("lightgray" if self.started else "white")+";}");
# print ('Hello World: '+ self.helloLineEdit.text())
else:
self.infoLabel.setStyleSheet("QLabel { color : red;}");
self.infoLabel.setText('No channel')
def setViewers(self, n):
if self.started:
self.infoLabel.setText('Viewers: %d/10' % n)
def errorStop(self):
if self.started:
self.handleButton()
self.infoLabel.setStyleSheet("QLabel { color : red;}");
self.infoLabel.setText('Channel offline')
def closeEvent(self, event):
global closed
# print 'closed'
closed = True
if __name__ == '__main__':
import sys
app = QtGui.QApplication(sys.argv)
twitchViewersWidget = TwitchViewersGui()
twitchViewersWidget.show()
runer = TwitchViewers(twitchViewersWidget)
threading.Thread(target = runer.run).start()
sys.exit(app.exec_())
from PyQt4.QtCore import pyqtSignal
from PyQt4.QtCore import *
import urllib2
import subprocess
import json
import sys
import threading
import time
from Queue import Queue
import collections
###################
channel_name = 'gatoluxo93'
###################
nombre_de_canal = ''
numberOfViewers = 10
builderThreads = 2
startTime = time.time()
numberOfSockets = 0
concurrent = 11
urls = []
urlsUsed = []
working = False
closed = False
class TwitchViewers():
def __init__(self, gui):
self.gui = gui
def getURL(self, nview): # Get tokens
global nombre_de_canal
output = subprocess.Popen([
"livestreamer",
"twitch.tv/"+nombre_de_canal,
"-j",
"--crunchyroll-purge-credentials"
], stdout=subprocess.PIPE,stdin=subprocess.PIPE,stder r=subprocess.PIPE, creationflags=0x08000000).communicate()[0]
# print json.loads(output)
# print output
try:
return json.loads(output)['streams']['worst']['url'] # Parse json and return the URL parameter
except Exception, e:
# print 'error get ', e, json.loads(output)
try:
if json.loads(output)['error'].find('No streams') != -1:
self.gui.trigger.emit()
except:
pass
def build(self): # Builds a set of tokens, aka viewers
global numberOfSockets
global numberOfViewers
global closed
global working
while True:
if closed:
break
# print 'si si ' + str(working) +" "+ str(closed)
if working and numberOfSockets < numberOfViewers:
numberOfSockets += 1
# print "Building viewers " + str(numberOfSockets) + "/" + str(numberOfViewers)
self.gui.setViewers(numberOfSockets)
url = self.getURL(numberOfSockets)
if url:
urls.append(url)
time.sleep(1)
def view(self): # Opens connections to send views
global numberOfSockets
global closed
while True:
if closed:
break
url=self.queue.get()
try:
request = urllib2.Request(url)
request.get_method = lambda : 'HEAD'
response = urllib2.urlopen(request).read()
except:
# print 'error view'
self.gui.trigger.emit()
if (url in urlsUsed):
urls.remove(url)
urlsUsed.remove(url)
numberOfSockets -= 1
else:
urlsUsed.append(url)
self.queue.task_done()
def run(self):
global closed
global working
for i in range(0, builderThreads):
threading.Thread(target = self.build).start()
self.queue=Queue(concurrent*2)
for i in range(concurrent):
try:
t=threading.Thread(target=self.view)
t.daemon=True
t.start()
except Exception, e:
pass
# print 'thread error ', e
while True:
if closed:
break
if working:
while (numberOfViewers != numberOfSockets): # Wait until sockets are built
if closed:
break
time.sleep(1)
try:
for url in urls:
# print url
self.queue.put(url.strip())
self.queue.join()
except KeyboardInterrupt:
sys.exit(1)
time.sleep(1)
class TwitchViewersGui(QtGui.QWidget):
trigger = pyqtSignal()
def __init__(self, parent=None):
super(TwitchViewersGui, self).__init__(parent)
helloLabel = QtGui.QLabel("Channel name")
self.helloLineEdit = QtGui.QLineEdit(channel_name)
self.helloLineEdit.setReadOnly(True)
self.button = QtGui.QPushButton('Start', self)
self.button.clicked.connect(self.handleButton)
self.started = False
self.infoLabel = QtGui.QLabel()
self.infoLabel.setStyleSheet("QLabel { color : green;}");
mainLayout = QtGui.QGridLayout()
mainLayout.addWidget(helloLabel, 0, 0)
mainLayout.addWidget(self.helloLineEdit, 0, 1)
mainLayout.addWidget(self.button, 1, 0)
mainLayout.addWidget(self.infoLabel, 1, 1)
self.setLayout(mainLayout)
self.setWindowTitle("+10 Twitch Viewers")
self.trigger.connect(self.errorStop)
def handleButton(self):
global working
global nombre_de_canal
global numberOfSockets
global urls
global urlsUsed
nombre_de_canal = str(self.helloLineEdit.text())
if nombre_de_canal:
numberOfSockets = 0
urls = []
urlsUsed = []
self.started = not self.started
working = self.started
self.infoLabel.setStyleSheet("QLabel { color : green;}");
self.infoLabel.setText('')
self.button.setText('Stop' if self.started else 'Start')
self.helloLineEdit.setStyleSheet("QLineEdit { background-color : "+("lightgray" if self.started else "white")+";}");
# print ('Hello World: '+ self.helloLineEdit.text())
else:
self.infoLabel.setStyleSheet("QLabel { color : red;}");
self.infoLabel.setText('No channel')
def setViewers(self, n):
if self.started:
self.infoLabel.setText('Viewers: %d/10' % n)
def errorStop(self):
if self.started:
self.handleButton()
self.infoLabel.setStyleSheet("QLabel { color : red;}");
self.infoLabel.setText('Channel offline')
def closeEvent(self, event):
global closed
# print 'closed'
closed = True
if __name__ == '__main__':
import sys
app = QtGui.QApplication(sys.argv)
twitchViewersWidget = TwitchViewersGui()
twitchViewersWidget.show()
runer = TwitchViewers(twitchViewersWidget)
threading.Thread(target = runer.run).start()
sys.exit(app.exec_())