我正在使用Pyinstaller在macosx上生成一个.app捆绑包,我的应用程序生成一个配置.ini,脚本版本工作得很完美,但是当它是一个.app时,它就不能工作了。 我使用ConfigParser进行读写。 我使用Pyside作为GUI。 它不生成我的.ini文件,因此它不读也不写。 是的,这是一个动画通知,厌倦了每次检查。在
代码:
import sys
import urllib2
import ConfigParser
import re
import time
import thread
import atexit
from datetime import date
import lxml.html as lx
from PySide.QtCore import *
from PySide.QtGui import *
from pync import Notifier
def layout_widgets(self, layout):
return (layout.itemAt(i) for i in range(layout.count()))
def notify(self):
while True:
config.read('animeConfig.ini')
for newAnime in animeNotify.xpath('//*[@id="frontpage_left_col"]//*[@class="blue"]/text()'):
if config.has_section(newAnime):
for newEp in animeNotify.xpath('//*[@id="frontpage_left_col"]//*[text()="'+newAnime+'"]/parent::h2/following-sibling::h3/a/text()'):
if not config.has_option(newAnime, newEp):
Notifier.notify(newEp+' has been uploaded!', title=newAnime+' '+newEp.lower(), open='http://www.animeseason.com' +
animeNotify.xpath('//*[@id="frontpage_left_col"]//*[text()="'+newEp+'"]/@href')[0])
m = re.findall('\d+', newEp)
config.set(newAnime, newEp, int(m[0]))
with open('animeConfig.ini', 'wb') as configFile:
config.write(configFile)
time.sleep(300)
def checkChecked(self):
while True:
config.read('animeConfig.ini')
for checkbox in self.layout_widgets(self.vLayout):
if checkbox.widget().isChecked() and not config.has_section(checkbox.widget().text()):
config.add_section(checkbox.widget().text())
for anime in animeList.xpath('//*[@class="series_alpha"]/li/span/preceding-sibling::a/text()'):
if config.has_section(anime):
self.EUrl = animeList.xpath('//*[@class="series_alpha"]/li/*[text()="'+anime+'"]/@href')[0]
self.EUrl = lx.parse(urllib2.urlopen("http://www.animeseason.com" + self.EUrl))
for ep in self.EUrl.xpath('//tr/*[@class="text_center"]/a/text()'):
config.set(anime, 'episode '+ep, ep)
with open('animeConfig.ini', 'wb') as configFile:
config.write(configFile)
elif not checkbox.widget().isChecked() and config.has_section(checkbox.widget().text()):
config.remove_section(checkbox.widget().text())
with open('animeConfig.ini', 'wb') as configFile:
config.write(configFile)
time.sleep(300)
我还使用线程模块,这样它们就可以同时运行了。 就这样:
^{pr2}$忽略了GUI部分,因为我想那不是很有趣。在
目前没有回答
相关问题 更多 >
编程相关推荐