0

I'm using Pyinstaller to make an .app bundle on Mac OS X, my app generates a config.ini, the script version worked flawlessly, but when it's an .app, it doesn't work. I'm using ConfigParser to read and write. I'm using Pyside for GUI. It doesn't generate my .ini file, hence it doesn't read or write. Yes, it's an Anime Notifier, got sick of checking it every time.

Code:

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)

I'm also using the thread module so they can operate simultaneously. Just like so:

thread.start_new_thread(self.notify, ())
thread.start_new_thread(self.checkChecked, ())

Left out the GUI part, because that isn't very interesting, I guess.

voider1
  • 1
  • 1
  • 2
  • It's impossible to answer your question as you're giving _no details_ about your app and the execution process. Please show us your code, describe the way you call the app now and you were calling it when it was just a Python script. Does your app have any GUI? _How exactly_ doesn't it work? I guess, the file you want is stored somewhere in your apps `Contents` folder _inside_ your apps `.app` package. – ForceBru Apr 03 '15 at 14:41
  • I'm very sorry, I'm not used to posting on Stackoverflow, I've changed it, and I've pasted the code that should work, but doesn't. – voider1 Apr 03 '15 at 15:48

0 Answers0