def main(): fpns_to_sync = [x for x in [x.strip() for x in open(os.path.join(utils.getScriptPath(), "fpns_to_sync.txt")).read().\ split("\n")] if x[0] != "#"] # there! # logger.debug("WILL SYNC "+",".join(fpns_to_sync)) if len(fpns_to_sync) == 0: logger.error("Nothing to sync") return -1 # validate legacy list -- used by diff validFPNs = diff.getValidFPNs() #logger.debug("Valid FPNS "+str(validFPNs)) logger.debug("connecting to sp") spsoap = spsoapclient.spsoapclient() sp_list_map = spsoap.get_lists_as_map() def _check_lists(): bad = False for ed in fpns_to_sync: try: sp_list_map[ed] except KeyError: logger.error("List to sync:|%s| not in SP"%ed) # for k in sp_list_map.keys(): # logger.debug("|%s|"%k) bad = True if ed not in validFPNs: logger.error("List to sync: |%s| not in ValidFPNs"%ed) bad = True return bad if _check_lists(): return -1 not1 = [x for x in fpns_to_sync if x not in validFPNs] if len(not1): print "fpns_to_sync not in validFPNS" print not1 not1 = [x for x in validFPNs if x not in fpns_to_sync] if len(not1): print "validFPNS not in fpns_to_sync" print not1 print "OK" return 0 # now = datetime.datetime.now() # nowfile = os.path.join(archive_dir, "now.csv") # spsfsync_runner.__dumpSF(nowfile) return 0
def main(): from tkinter import PhotoImage global root root = Tk() icon = PhotoImage(file=utils.getScriptPath() + "/images/haus_18x16.png") root.call('wm', 'iconphoto', root._w, icon) if 'win' not in sys.platform: style = ttk.Style() style.theme_use('clam') wv = WV(root) global ctrl ctrl = WvController(wv) #wv.after(1, lambda: dlg.focus_force()) root.option_add('*Dialog.msg.font', 'Helvetica 11') wv.bind("<Visibility>", onFirstShow) root.mainloop()
# # #width = root.winfo_screenwidth() # #width = root.winfo_width() # #height = int(root.winfo_screenheight()/2) # #root.geometry('%sx%s' % (900, height)) # # #wv.bind("<Visibility>", show) # # root.option_add('*Dialog.msg.font', 'Helvetica 11') # # wv.mainloop() if __name__ == '__main__': print("path: ", sys.path) print("current work directory: ", os.getcwd()) print("scriptpath: ", utils.getScriptPath()) main() """ todo - Tab Page Jahresdaten implementieren (für *eine* Wohnung) - Dialog Jahresdaten implementieren (Vergleich *aller* Wohnungen) - Bug: Wohnung löschen geht nicht - Bug: Löschen der letzten Rechnung: Fehler wird gemeldet, letzte Rechnung bleibt stehen, ist beim neuen LAden dann aber doch weg - zusätzliche Plausi bei Mtl. Ein-Auszahlungen: Es darf keine Änderung von Miete, NK, HG WÄHREND eines Monats geben, sonst laufen die Jahresdaten und die AnlageV-Berechnung falsch. - Verwalter neu/ändern implementieren """
def getValidFPNs(): p = open(os.path.join(utils.getScriptPath(), "fpns.txt")).read().split("\n") return [px.strip() for px in p if px != "" and px.strip()[0] != "#" and px.strip() != ""]
import os.path import datetime import commands import uu import curl import fcntl mailhost = "mail.advisen.com" administrators = "[email protected],[email protected]" mailsender = "*****@*****.**" logger = createLogger("pushreports") sleepTime = 5 configFile = "pushreports.cfg" configPath = os.path.join(getScriptPath(), configFile) pid_file = os.path.join(getScriptPath(), 'program.pid') fp = open(pid_file, 'w') try: fcntl.lockf(fp, fcntl.LOCK_EX | fcntl.LOCK_NB) except IOError: logger.error("Another instance is already running") sys.exit(0) class PRException(sf.SFException): def __init__(self, msg): self.msg = msg class Mailer: def mailAttach(self, subject, body, type="text"):
def getGrundsteuerDefs() -> list: columnsDefs = ColumnDefsProvider._getWidgetDefs(utils.getScriptPath() + "/grundsteuer.json") return columnsDefs
def main(archive_dir, debug = 0): if not os.path.isdir(archive_dir): print "archive_dir "+archive_dir+" not found" return -1 logger.debug("DEBUG = "+str(debug)) fpns_to_sync = [x for x in [x.strip() for x in open(os.path.join(utils.getScriptPath(), "fpns_to_sync.txt")).read().\ split("\n")] if x[0] != "#"] # there! logger.debug("WILL SYNC "+",".join(fpns_to_sync)) if len(fpns_to_sync) == 0: logger.error("Nothing to sync") return -1 logger.debug("connecting to sp") spsoap = spsoapclient.spsoapclient() sp_list_map = spsoap.get_lists_as_map() def _check_lists(): bad = False for ed in fpns_to_sync: try: sp_list_map[ed] except KeyError: logger.error("List to sync:%s not in SP"%ed) bad = True return bad if _check_lists(): return -1 rmap = spsoap.get_recips_as_map(os.path.join(tempdir, utils.temp_name("sp_export.csv"))) logger.debug("rmap len %d"%len(rmap)) now = datetime.datetime.now() nowfile = os.path.join(archive_dir, "now.csv") prevfile = os.path.join(archive_dir, "prev.csv") if debug != 1: if not os.path.isfile(nowfile): logger.debug("there is no now file - wtf do we do") else: if os.path.isfile(prevfile): n = os.path.join(archive_dir, "prev_%04d%02d%02d.csv"%(now.year, now.month, now.day)) if os.path.isfile(n): os.remove(n) os.rename(prevfile, n) os.rename(nowfile, prevfile) __dumpSF(nowfile) rc = spsfsync.main(nowfile, rmap, None, send_emails_to) import diff adds, deletes = diff.diff(nowfile, prevfile) if len(adds) == 0 and len(deletes) == 0: logger.debug("Nothing to do") return 0 good_adds = [] bad_adds = [] good_dels = [] bad_dels = [] for ed in fpns_to_sync: listid = sp_list_map[ed] logger.debug("DOING %s - %d"%(ed, listid)) if ed in adds: for a in adds[ed]: logger.debug("add %s to %s id %d"%(a, ed, listid)) if a in rmap: recip_id = rmap[a][0] else: try: recip_id = spsoap.create_recip(a) except spsoapclient.spsoapclient_exception, e: bad_adds.append("%s to %s failed with %s"%(a,ed,e.what)) continue rc = spsoap.add_recip_to_list(int(listid), int(recip_id)) good_adds.append("%s to %s"%(a, ed)) logger.debug("DOING dels %d"%(len(deletes))) if ed in deletes: for a in deletes[ed]: logger.debug("delete %s from %s id %d"%(a, ed, listid)) if a in rmap: recip_id = rmap[a][0] mailing_id = rmap[a][2] rc = spsoap.delete_recip_from_list(int(listid), int(recip_id), int(mailing_id)) good_dels.append("%s from %s"%(a, ed)) else: bad_dels.append("%s unsub from %s is not in recip list of SP"%(a, ed))
def getSonstigeEinAusDefs() -> list: columnsDefs = ColumnDefsProvider._getWidgetDefs(utils.getScriptPath() + "/sonstigeeinaus.json") return columnsDefs
def getMonatlicheEinAusDefs() -> list: columnsDefs = ColumnDefsProvider._getWidgetDefs( utils.getScriptPath() + "/monatlicheeinaus.json") return columnsDefs
def getRechnungDefs() -> list: columnsDefs = ColumnDefsProvider._getWidgetDefs(utils.getScriptPath() + "/rechnung.json") return columnsDefs
from libs import * import utils from business import DataProvider, DataError, ServiceException from vermietercontroller import VermieterController from verwaltercontroller import VerwalterController, VerwalterModifiedAction from mywidgets import TextEntry from actions import Action from stammdatenview import StammdatenView, StammdatenAction from interfaces import XWohnungDaten, XVerwalter, XVermieter, \ XVermieterList, XVerwalterList import datehelper print(utils.getScriptPath()) class StammdatenController: def __init__(self, dataProvider: DataProvider, stammdatenView: StammdatenView): self._dataProvider = dataProvider self._view = stammdatenView self._whg_id = None self._vermieterDic: Dict[int, str] = {} #dictionary of all vermieter self._verwalterDic: Dict[int, str] = {} #dictionary of all verwalter self._actionCompletedCallbacks = list() self._xwohnungDataTmp = None def startWork(self) -> None: self._view.registerModifyCallback(self.onStammdatenModify) self._view.registerActionCallback(self.onStammdatenAction) self._view.setVermieterList(self._getVermieterList()) self._view.setVerwalterList(self._getVerwalterList())
global p_main, p_steam, p_run, p_update import utils p_main = utils.getScriptPath() + "/working" p_steam = p_main + "/steamcmd" p_ark = p_main + "/ark" p_run = p_ark + "/run" p_update = p_ark + "/update" def main(): if sys.argv[1] == "init": os.makedirs(p_main) os.makedirs(p_steam) os.makedirs(p_run) os.makedirs(p_update) server_manager.install_steamcmd() if sys.argv[1] == "start": print("Versuche Update Server ...") updated = update_manager.try_update(p_run) print("Versuche Update Mods ...") updated_mods = update_manager.try_update_mods(p_run, config.mods) if(updated and updated_mods): update_manager.backup(p_run) ark.run(p_run) if __name__ == "__main__": import os import sys import update_manager import ark_manager as ark