From 4c6521fb489dc48d407d4802917047cfcb03f05c Mon Sep 17 00:00:00 2001 From: Christian Hattemer Date: Tue, 19 Apr 2016 14:04:50 +0200 Subject: [PATCH] =?UTF-8?q?Unn=C3=B6tigen=20Leerraum=20entfernen,=20einfac?= =?UTF-8?q?he=20Anf=C3=BChrungszeichen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- setup/cam | 3 +- setup/lib/cli.py | 24 +++++++------- setup/lib/config_at.py | 7 ++-- setup/lib/environments.py | 1 + setup/lib/functions.py | 68 ++++++++++++++++++--------------------- 5 files changed, 49 insertions(+), 54 deletions(-) mode change 100755 => 100644 setup/lib/functions.py diff --git a/setup/cam b/setup/cam index 697c9f10..4fbb99d3 100755 --- a/setup/cam +++ b/setup/cam @@ -1,5 +1,6 @@ #!/usr/bin/env python + from lib import cli -if __name__ == "__main__": +if __name__ == '__main__': cli.main() diff --git a/setup/lib/cli.py b/setup/lib/cli.py index f549cbb3..20094d33 100755 --- a/setup/lib/cli.py +++ b/setup/lib/cli.py @@ -1,27 +1,27 @@ # -*- coding: utf-8 -*- -import urlparse + import sys +import urlparse from config_at import Config from environments import ENVIRONMENTS, Environment from functions import CamadeusFunctions def main(): - def _usage(): print '\nVerwendung: cam.py [/]\n' print 'Commands:\n' print ' create Neue Datenbank erstellen' print ' create_from_dump Neue Datenbank von Dump erstellen' - print ' setup Modulinstallation. Konfigurationen.' - print ' setup_part setup_function Aufruf eines einzelnen Setup Schrittes.' - print ' "setup_part info" listet die verfügbaren Setup Schritte auf.' + print ' setup Modulinstallation, Konfigurationen' + print ' setup_part setup_function Aufruf eines einzelnen Setup-Schrittes' + print ' "setup_part info" listet die verfügbaren Setup-Schritte auf' print ' rollout Setzt Dokumentnummern, importiert Benutzer, setzt cam_dmi auf noupdate, ...' print ' update module_name Modul updaten' - print ' install modul_name Modul installieren' - print ' uninstall modul_name Modul deinstallieren' - print ' cancel_upgrade modul_name Abbruch Modulinstallation' - print ' update_modules Update aller Module in der config Modulliste.' + print ' install module_name Modul installieren' + print ' uninstall module_name Modul deinstallieren' + print ' cancel_upgrade module_name Abbruch Modulinstallation' + print ' update_modules Update aller Module in der config-Modulliste' print ' update_all Update aller verfügbaren Module' print ' list-envs Environments auflisten' print ' anonym Daten anonymisieren (Namen, Adresse, E-Mail, ...)' @@ -180,7 +180,7 @@ def main(): if ((argv[2] == 'info') or (not (argv[2] in setup_methods))): print '\nVerfügbare setup Methoden: ' + str(setup_methods) + '\n' return - + methods = [ 'login', argv[2], @@ -190,13 +190,13 @@ def main(): methods = [ 'login', 'make_anonymous', - ] + ] if cmd == 'invalidate_email': methods = [ 'login', 'invalidate_email', - ] + ] if not methods: print 'Unbekanntes Kommando' diff --git a/setup/lib/config_at.py b/setup/lib/config_at.py index 6da820df..757b9056 100644 --- a/setup/lib/config_at.py +++ b/setup/lib/config_at.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- + class Config(): def __init__(self): - - self.dump_file = "upgraded_file_name.dump" - + self.dump_file = 'upgraded_file_name.dump' + self.module_name = None self.lang = 'de_DE' # de_DE, en_US self.chart_of_accounts = 'l10n_at' @@ -243,7 +243,6 @@ class Config(): self.default_values = [ # ir.values #('product.template', 'type', 'service'), #('product.template', 'type', 'XML:xmlid'), #mit prefix "XML:" kann eine XML ID übergeben werden - ] self.data_updates = { diff --git a/setup/lib/environments.py b/setup/lib/environments.py index e7c506fc..29ab25dc 100644 --- a/setup/lib/environments.py +++ b/setup/lib/environments.py @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- + class Environment(): def __init__(self, host, port, dbname, username, pwd=None, super_admin_pw=None, basic_auth=None): self.host = host diff --git a/setup/lib/functions.py b/setup/lib/functions.py old mode 100755 new mode 100644 index a0872f7f..a3fb1be7 --- a/setup/lib/functions.py +++ b/setup/lib/functions.py @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- + import base64 import json import pprint @@ -42,7 +43,7 @@ class CamadeusFunctions(): } url = '%s:%s/web/database/restore?restore_pwd=%s&new_db=%s&mode=restore' url %= (self.env.host, self.env.port, self.env.admin_pw, self.env.dbname) - print "Request: " + url + print 'Request: ' + url res = requests.post(url, files=files, verify=False) if (res.status_code != 200): return False @@ -420,7 +421,7 @@ class CamadeusFunctions(): invalid_ids = self._execute('account.fiscal.position', 'search', [('name', 'not in', c.valid_fiscal_positions)]) self._execute('account.fiscal.position', 'write', invalid_ids, {'active': False}) - # Mappings inaktiver Steuern löschen (also wenn rechte Seite eine inaktive Steuer ist, wie z.B "strf. i.g.L")) + # Mappings inaktiver Steuern löschen (also wenn rechte Seite eine inaktive Steuer ist, wie z. B "strf. i.g.L")) valid_position_ids = self._execute('account.fiscal.position', 'search', [('name', 'in', c.valid_fiscal_positions)]) valid_tax_ids = self._execute('account.tax', 'search', [('parent_id', '=', False)]) @@ -656,15 +657,14 @@ class CamadeusFunctions(): """Defaultwerte für Dokumente setzen""" for model,field,value in self.config.default_values: - - #falls XML ID (prefix "XML:") dann die DB ID holen + # Falls XML ID (prefix "XML:") dann die DB ID holen if value[0:4] == 'XML:': xml_id = value[4:] dummy,dummy2,res_id = self._execute('ir.model.data', 'xmlid_lookup', xml_id) if not res_id: - raise Exception("Defaultwerte Anlegen: XML ID %s nicht vorhanden!" % (xml_id)) + raise Exception('Defaultwerte anlegen: XML ID %s nicht vorhanden!' % (xml_id)) value = res_id - + vals = { 'name': field, 'model': model, @@ -680,11 +680,10 @@ class CamadeusFunctions(): self._execute('ir.values', 'create', vals) return True - def update_special_values(self): """Spezialwerte setzen""" - - #Z.B.: + + #Z. B.: ## Lösche alle Anreden außer Herr und Frau #data_deletes = [ # 'base.res_partner_title_doctor', @@ -698,14 +697,13 @@ class CamadeusFunctions(): #] #for xml_id in data_deletes: # try: - # dummy,model,res_id = self._execute('ir.model.data', 'xmlid_lookup', xml_id) + # dummy,model,res_id = self._execute('ir.model.data', 'xmlid_lookup', xml_id) # self._execute(model, 'unlink', [res_id]) # except: # pass return True - - + def update_values(self): """Existierende Daten aktualisieren""" @@ -740,9 +738,9 @@ class CamadeusFunctions(): else: return False return True - + def invalidate_email(self): - """E-Mail adressen @ durch # erstezen um unbeabsichtigen E-Mail Versand zu vermeiden""" + """In E-Mail-Adressen @ durch # ersetzen, um unbeabsichtigen E-Mail-Versand zu vermeiden""" #E-Mail adressen von res_partner: @ -> # p_ids = self._execute('res.partner', 'search', [('email','ilike','%@%')]) @@ -754,7 +752,7 @@ class CamadeusFunctions(): self._execute('res.partner', 'write', [id], {'email': new_email}) def finance_config(self): - """Basiskonfiguration für Finanzen Laden""" + """Basiskonfiguration für Finanzen laden""" if hasattr(self.config, 'finance_config'): vals = self._execute('account.config.settings', 'default_get', []) @@ -774,24 +772,23 @@ class CamadeusFunctions(): res &= self.make_anonymous_one('make_anonymous_mailserver') res &= self.make_anonymous_one('make_anonymous_cron') return res - - + def make_anonymous_one(self, func_name): """Anonymisieren der Daten ein Schritt""" - + try: getattr(self, func_name)() - print '.............. ' + func_name + ": OK" + print '.............. ' + func_name + ': OK' except: - print '.............. ' + func_name + ": ERROR!!!" + print '.............. ' + func_name + ': ERROR!!!' return False return True - + def make_anonymous_partner(self): ids = self._execute('res.partner', 'search', []) for id in ids: vals = { - 'name': "Partner %s" % id, + 'name': 'Partner %s' % id, 'street': '----', 'email': 'test@example.com', } @@ -802,43 +799,43 @@ class CamadeusFunctions(): ids = self._execute('project.project', 'search', []) for id in ids: vals = { - 'name': "Projekt %s" % id, + 'name': 'Projekt %s' % id, } - self._execute('project.project', 'write', [id], vals) - + self._execute('project.project', 'write', [id], vals) + #Tasks ids = self._execute('project.task', 'search', []) for id in ids: vals = { - 'name': "Aufgabe %s" % id, + 'name': 'Aufgabe %s' % id, } - self._execute('project.task', 'write', [id], vals) - + self._execute('project.task', 'write', [id], vals) + def make_anonymous_employee(self): if (self._execute('ir.module.module', 'search', [('name', '=', 'hr'), ('state', '=', 'installed')])): ids = self._execute('hr.employee', 'search', []) for id in ids: vals = { - 'name': "Mitarbeiter %s" % id, - 'work_email': 'test@example.com', + 'name': 'Mitarbeiter %s' % id, + 'work_email': 'test@example.com', } self._execute('hr.employee','write', [id], vals) - + def make_anonymous_leads(self): if (self._execute('ir.module.module', 'search', [('name', '=', 'crm'), ('state', '=', 'installed')])): ids = self._execute('crm.lead', 'search', []) for id in ids: vals = { - 'name': "Lead %s" % id, + 'name': 'Lead %s' % id, 'email_from': 'test@example.com', 'description': '', } - ids = self._execute('crm.lead','write', [id], vals) + ids = self._execute('crm.lead','write', [id], vals) def make_anonymous_mailserver(self): server_ids = self._execute('ir.mail_server', 'search', []) self._execute('ir.mail_server', 'write', server_ids, {'active': False}) - + server_ids = self._execute('fetchmail.server', 'search', []) self._execute('fetchmail.server', 'unlink', server_ids) @@ -846,6 +843,3 @@ class CamadeusFunctions(): cron_ids = self._execute('ir.cron', 'search', []) if cron_ids: self._execute('ir.cron', 'write', cron_ids, {'active': False}) - - - \ No newline at end of file