Unnötigen Leerraum entfernen, einfache Anführungszeichen
							parent
							
								
									1260421e7f
								
							
						
					
					
						commit
						4c6521fb48
					
				|  | @ -1,5 +1,6 @@ | ||||||
| #!/usr/bin/env python | #!/usr/bin/env python | ||||||
|  | 
 | ||||||
| from lib import cli | from lib import cli | ||||||
| 
 | 
 | ||||||
| if __name__ == "__main__": | if __name__ == '__main__': | ||||||
|     cli.main() |     cli.main() | ||||||
|  |  | ||||||
|  | @ -1,27 +1,27 @@ | ||||||
| # -*- coding: utf-8 -*- | # -*- coding: utf-8 -*- | ||||||
| import urlparse | 
 | ||||||
| import sys | import sys | ||||||
|  | import urlparse | ||||||
| 
 | 
 | ||||||
| from config_at import Config | from config_at import Config | ||||||
| from environments import ENVIRONMENTS, Environment | from environments import ENVIRONMENTS, Environment | ||||||
| from functions import CamadeusFunctions | from functions import CamadeusFunctions | ||||||
| 
 | 
 | ||||||
| def main(): | def main(): | ||||||
| 
 |  | ||||||
|     def _usage(): |     def _usage(): | ||||||
|         print '\nVerwendung: cam.py <environment> <command> [<module_name>/<setup_function>]\n' |         print '\nVerwendung: cam.py <environment> <command> [<module_name>/<setup_function>]\n' | ||||||
|         print 'Commands:\n' |         print 'Commands:\n' | ||||||
|         print '   create                     Neue Datenbank erstellen' |         print '   create                     Neue Datenbank erstellen' | ||||||
|         print '   create_from_dump           Neue Datenbank von Dump erstellen' |         print '   create_from_dump           Neue Datenbank von Dump erstellen' | ||||||
|         print '   setup                      Modulinstallation. Konfigurationen.' |         print '   setup                      Modulinstallation, Konfigurationen' | ||||||
|         print '   setup_part setup_function  Aufruf eines einzelnen Setup Schrittes.' |         print '   setup_part setup_function  Aufruf eines einzelnen Setup-Schrittes' | ||||||
|         print '                              "setup_part info" listet die verfügbaren Setup Schritte auf.' |         print '                              "setup_part info" listet die verfügbaren Setup-Schritte auf' | ||||||
|         print '   rollout                    Setzt Dokumentnummern, importiert Benutzer, setzt cam_dmi auf noupdate, ...' |         print '   rollout                    Setzt Dokumentnummern, importiert Benutzer, setzt cam_dmi auf noupdate, ...' | ||||||
|         print '   update module_name         Modul updaten' |         print '   update module_name         Modul updaten' | ||||||
|         print '   install modul_name         Modul installieren' |         print '   install module_name        Modul installieren' | ||||||
|         print '   uninstall modul_name       Modul deinstallieren' |         print '   uninstall module_name      Modul deinstallieren' | ||||||
|         print '   cancel_upgrade modul_name  Abbruch Modulinstallation' |         print '   cancel_upgrade module_name Abbruch Modulinstallation' | ||||||
|         print '   update_modules             Update aller Module in der config Modulliste.' |         print '   update_modules             Update aller Module in der config-Modulliste' | ||||||
|         print '   update_all                 Update aller verfügbaren Module' |         print '   update_all                 Update aller verfügbaren Module' | ||||||
|         print '   list-envs                  Environments auflisten' |         print '   list-envs                  Environments auflisten' | ||||||
|         print '   anonym                     Daten anonymisieren (Namen, Adresse, E-Mail, ...)' |         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))): |         if ((argv[2] == 'info') or (not (argv[2] in setup_methods))): | ||||||
|             print '\nVerfügbare setup Methoden: ' + str(setup_methods) + '\n' |             print '\nVerfügbare setup Methoden: ' + str(setup_methods) + '\n' | ||||||
|             return |             return | ||||||
|      | 
 | ||||||
|         methods = [ |         methods = [ | ||||||
|             'login', |             'login', | ||||||
|             argv[2], |             argv[2], | ||||||
|  | @ -190,13 +190,13 @@ def main(): | ||||||
|         methods = [ |         methods = [ | ||||||
|             'login', |             'login', | ||||||
|             'make_anonymous', |             'make_anonymous', | ||||||
|         ]   |         ] | ||||||
| 
 | 
 | ||||||
|     if cmd == 'invalidate_email': |     if cmd == 'invalidate_email': | ||||||
|         methods = [ |         methods = [ | ||||||
|             'login', |             'login', | ||||||
|             'invalidate_email', |             'invalidate_email', | ||||||
|         ]   |         ] | ||||||
| 
 | 
 | ||||||
|     if not methods: |     if not methods: | ||||||
|         print 'Unbekanntes Kommando' |         print 'Unbekanntes Kommando' | ||||||
|  |  | ||||||
|  | @ -1,9 +1,9 @@ | ||||||
| # -*- coding: utf-8 -*- | # -*- coding: utf-8 -*- | ||||||
|  | 
 | ||||||
| class Config(): | class Config(): | ||||||
|     def __init__(self): |     def __init__(self): | ||||||
|          |         self.dump_file = 'upgraded_file_name.dump' | ||||||
|         self.dump_file = "upgraded_file_name.dump" | 
 | ||||||
|          |  | ||||||
|         self.module_name = None |         self.module_name = None | ||||||
|         self.lang = 'de_DE' # de_DE, en_US |         self.lang = 'de_DE' # de_DE, en_US | ||||||
|         self.chart_of_accounts = 'l10n_at' |         self.chart_of_accounts = 'l10n_at' | ||||||
|  | @ -243,7 +243,6 @@ class Config(): | ||||||
|         self.default_values = [   # ir.values |         self.default_values = [   # ir.values | ||||||
|             #('product.template', 'type', 'service'), |             #('product.template', 'type', 'service'), | ||||||
|             #('product.template', 'type', 'XML:xmlid'),    #mit prefix "XML:" kann eine XML ID übergeben werden |             #('product.template', 'type', 'XML:xmlid'),    #mit prefix "XML:" kann eine XML ID übergeben werden | ||||||
|              |  | ||||||
|         ] |         ] | ||||||
| 
 | 
 | ||||||
|         self.data_updates = { |         self.data_updates = { | ||||||
|  |  | ||||||
|  | @ -1,4 +1,5 @@ | ||||||
| # -*- coding: utf-8 -*- | # -*- coding: utf-8 -*- | ||||||
|  | 
 | ||||||
| class Environment(): | class Environment(): | ||||||
|     def __init__(self, host, port, dbname, username, pwd=None, super_admin_pw=None, basic_auth=None): |     def __init__(self, host, port, dbname, username, pwd=None, super_admin_pw=None, basic_auth=None): | ||||||
|         self.host = host |         self.host = host | ||||||
|  |  | ||||||
|  | @ -1,4 +1,5 @@ | ||||||
| # -*- coding: utf-8 -*- | # -*- coding: utf-8 -*- | ||||||
|  | 
 | ||||||
| import base64 | import base64 | ||||||
| import json | import json | ||||||
| import pprint | import pprint | ||||||
|  | @ -42,7 +43,7 @@ class CamadeusFunctions(): | ||||||
|         } |         } | ||||||
|         url = '%s:%s/web/database/restore?restore_pwd=%s&new_db=%s&mode=restore' |         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) |         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) |         res = requests.post(url, files=files, verify=False) | ||||||
|         if (res.status_code != 200): |         if (res.status_code != 200): | ||||||
|             return False |             return False | ||||||
|  | @ -420,7 +421,7 @@ class CamadeusFunctions(): | ||||||
|         invalid_ids = self._execute('account.fiscal.position', 'search', [('name', 'not in', c.valid_fiscal_positions)]) |         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}) |         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_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)]) |         valid_tax_ids = self._execute('account.tax', 'search', [('parent_id', '=', False)]) | ||||||
| 
 | 
 | ||||||
|  | @ -656,15 +657,14 @@ class CamadeusFunctions(): | ||||||
|         """Defaultwerte für Dokumente setzen""" |         """Defaultwerte für Dokumente setzen""" | ||||||
| 
 | 
 | ||||||
|         for model,field,value in self.config.default_values: |         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:': |             if value[0:4] == 'XML:': | ||||||
|                 xml_id = value[4:] |                 xml_id = value[4:] | ||||||
|                 dummy,dummy2,res_id = self._execute('ir.model.data', 'xmlid_lookup', xml_id) |                 dummy,dummy2,res_id = self._execute('ir.model.data', 'xmlid_lookup', xml_id) | ||||||
|                 if not res_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 |                 value = res_id | ||||||
|              | 
 | ||||||
|             vals = { |             vals = { | ||||||
|                 'name': field, |                 'name': field, | ||||||
|                 'model': model, |                 'model': model, | ||||||
|  | @ -680,11 +680,10 @@ class CamadeusFunctions(): | ||||||
|                 self._execute('ir.values', 'create', vals) |                 self._execute('ir.values', 'create', vals) | ||||||
|         return True |         return True | ||||||
| 
 | 
 | ||||||
| 
 |  | ||||||
|     def update_special_values(self): |     def update_special_values(self): | ||||||
|         """Spezialwerte setzen""" |         """Spezialwerte setzen""" | ||||||
|          | 
 | ||||||
|         #Z.B.:  |         #Z. B.: | ||||||
|         ## Lösche alle Anreden außer Herr und Frau |         ## Lösche alle Anreden außer Herr und Frau | ||||||
|         #data_deletes = [ |         #data_deletes = [ | ||||||
|         #    'base.res_partner_title_doctor', |         #    'base.res_partner_title_doctor', | ||||||
|  | @ -698,14 +697,13 @@ class CamadeusFunctions(): | ||||||
|         #] |         #] | ||||||
|         #for xml_id in data_deletes: |         #for xml_id in data_deletes: | ||||||
|         #    try: |         #    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]) |         #        self._execute(model, 'unlink',  [res_id]) | ||||||
|         #    except: |         #    except: | ||||||
|         #        pass |         #        pass | ||||||
| 
 | 
 | ||||||
|         return True |         return True | ||||||
|      | 
 | ||||||
|      |  | ||||||
|     def update_values(self): |     def update_values(self): | ||||||
|         """Existierende Daten aktualisieren""" |         """Existierende Daten aktualisieren""" | ||||||
| 
 | 
 | ||||||
|  | @ -740,9 +738,9 @@ class CamadeusFunctions(): | ||||||
|             else: |             else: | ||||||
|                 return False |                 return False | ||||||
|         return True |         return True | ||||||
|      | 
 | ||||||
|     def invalidate_email(self): |     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: @ -> # |         #E-Mail adressen von res_partner: @ -> # | ||||||
|         p_ids = self._execute('res.partner', 'search', [('email','ilike','%@%')]) |         p_ids = self._execute('res.partner', 'search', [('email','ilike','%@%')]) | ||||||
|  | @ -754,7 +752,7 @@ class CamadeusFunctions(): | ||||||
|             self._execute('res.partner', 'write', [id], {'email': new_email}) |             self._execute('res.partner', 'write', [id], {'email': new_email}) | ||||||
| 
 | 
 | ||||||
|     def finance_config(self): |     def finance_config(self): | ||||||
|         """Basiskonfiguration für Finanzen Laden""" |         """Basiskonfiguration für Finanzen laden""" | ||||||
| 
 | 
 | ||||||
|         if hasattr(self.config, 'finance_config'): |         if hasattr(self.config, 'finance_config'): | ||||||
|             vals = self._execute('account.config.settings', 'default_get', []) |             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_mailserver') | ||||||
|         res &= self.make_anonymous_one('make_anonymous_cron') |         res &= self.make_anonymous_one('make_anonymous_cron') | ||||||
|         return res |         return res | ||||||
|          | 
 | ||||||
|          |  | ||||||
|     def make_anonymous_one(self, func_name): |     def make_anonymous_one(self, func_name): | ||||||
|         """Anonymisieren der Daten ein Schritt""" |         """Anonymisieren der Daten ein Schritt""" | ||||||
|          | 
 | ||||||
|         try: |         try: | ||||||
|             getattr(self, func_name)() |             getattr(self, func_name)() | ||||||
|             print '.............. ' + func_name + ": OK"  |             print '.............. ' + func_name + ': OK' | ||||||
|         except: |         except: | ||||||
|             print '.............. ' + func_name + ": ERROR!!!" |             print '.............. ' + func_name + ': ERROR!!!' | ||||||
|             return False |             return False | ||||||
|         return True |         return True | ||||||
|   | 
 | ||||||
|     def make_anonymous_partner(self): |     def make_anonymous_partner(self): | ||||||
|         ids = self._execute('res.partner', 'search', []) |         ids = self._execute('res.partner', 'search', []) | ||||||
|         for id in ids: |         for id in ids: | ||||||
|             vals = { |             vals = { | ||||||
|                     'name': "Partner %s" % id, |                     'name': 'Partner %s' % id, | ||||||
|                     'street': '----', |                     'street': '----', | ||||||
|                     'email': 'test@example.com', |                     'email': 'test@example.com', | ||||||
|                     } |                     } | ||||||
|  | @ -802,43 +799,43 @@ class CamadeusFunctions(): | ||||||
|             ids = self._execute('project.project', 'search', []) |             ids = self._execute('project.project', 'search', []) | ||||||
|             for id in ids: |             for id in ids: | ||||||
|                 vals = { |                 vals = { | ||||||
|                         'name': "Projekt %s" % id, |                         'name': 'Projekt %s' % id, | ||||||
|                         } |                         } | ||||||
|                 self._execute('project.project', 'write', [id], vals)         |                 self._execute('project.project', 'write', [id], vals) | ||||||
|       | 
 | ||||||
|             #Tasks |             #Tasks | ||||||
|             ids = self._execute('project.task', 'search', []) |             ids = self._execute('project.task', 'search', []) | ||||||
|             for id in ids: |             for id in ids: | ||||||
|                 vals = { |                 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): |     def make_anonymous_employee(self): | ||||||
|         if (self._execute('ir.module.module', 'search', [('name', '=', 'hr'), ('state', '=', 'installed')])): |         if (self._execute('ir.module.module', 'search', [('name', '=', 'hr'), ('state', '=', 'installed')])): | ||||||
|             ids = self._execute('hr.employee', 'search', []) |             ids = self._execute('hr.employee', 'search', []) | ||||||
|             for id in ids: |             for id in ids: | ||||||
|                 vals = { |                 vals = { | ||||||
|                         'name': "Mitarbeiter %s" % id, |                         'name': 'Mitarbeiter %s' % id, | ||||||
|                         'work_email': 'test@example.com',                 |                         'work_email': 'test@example.com', | ||||||
|                         } |                         } | ||||||
|                 self._execute('hr.employee','write', [id], vals) |                 self._execute('hr.employee','write', [id], vals) | ||||||
|                  | 
 | ||||||
|     def make_anonymous_leads(self): |     def make_anonymous_leads(self): | ||||||
|         if (self._execute('ir.module.module', 'search', [('name', '=', 'crm'), ('state', '=', 'installed')])): |         if (self._execute('ir.module.module', 'search', [('name', '=', 'crm'), ('state', '=', 'installed')])): | ||||||
|             ids = self._execute('crm.lead', 'search', []) |             ids = self._execute('crm.lead', 'search', []) | ||||||
|             for id in ids: |             for id in ids: | ||||||
|                 vals = { |                 vals = { | ||||||
|                         'name': "Lead %s" % id,   |                         'name': 'Lead %s' % id, | ||||||
|                         'email_from': 'test@example.com', |                         'email_from': 'test@example.com', | ||||||
|                         'description': '', |                         'description': '', | ||||||
|                         } |                         } | ||||||
|                 ids = self._execute('crm.lead','write', [id], vals)         |                 ids = self._execute('crm.lead','write', [id], vals) | ||||||
| 
 | 
 | ||||||
|     def make_anonymous_mailserver(self): |     def make_anonymous_mailserver(self): | ||||||
|         server_ids = self._execute('ir.mail_server', 'search', []) |         server_ids = self._execute('ir.mail_server', 'search', []) | ||||||
|         self._execute('ir.mail_server', 'write', server_ids, {'active': False}) |         self._execute('ir.mail_server', 'write', server_ids, {'active': False}) | ||||||
|   | 
 | ||||||
|         server_ids = self._execute('fetchmail.server', 'search', []) |         server_ids = self._execute('fetchmail.server', 'search', []) | ||||||
|         self._execute('fetchmail.server', 'unlink', server_ids) |         self._execute('fetchmail.server', 'unlink', server_ids) | ||||||
| 
 | 
 | ||||||
|  | @ -846,6 +843,3 @@ class CamadeusFunctions(): | ||||||
|         cron_ids = self._execute('ir.cron', 'search', []) |         cron_ids = self._execute('ir.cron', 'search', []) | ||||||
|         if cron_ids: |         if cron_ids: | ||||||
|             self._execute('ir.cron', 'write', cron_ids, {'active': False}) |             self._execute('ir.cron', 'write', cron_ids, {'active': False}) | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
|      |  | ||||||
		Loading…
	
		Reference in New Issue