~unifield-team/unifield-wm/us-808-sync

« back to all changes in this revision

Viewing changes to sync_client/backup.py

  • Committer: jf
  • Date: 2015-11-23 16:39:39 UTC
  • mfrom: (601.1.14 unifield-sync)
  • Revision ID: jfb@tempo-consulting.fr-20151123163939-yf7d3zfy48vzpyzv
Tags: uf2.0rc1
US-703 [IMP] Sync server: remove puller
US-703 [IMP] Split data pulled ids
SP-190 [IMP] Data push: do not browse all records
SP-199 [IMP] Do not send multi delete updates for the same record
US-684 [IMP] Close and remove cursor used by sync process
Us-684 [IMP] Don't load db dump file in memory

lp:~unifield-team/unifield-wm/us-703-sync-qt

Changes in sync_server.sync_rule.csv:
remove duplicated rule to generate delete updates on:
    - account.target.costcenter #107, done @rule #113
    - res.currency.rate #128, done @rule #106
    - cost.center.distribution.line #202 and #203, done @rule #201
    - funding.pool.distribution.line #211, done @rule #210
    - account.cashbox.line #404, done @rule #402
    - account.move.line #417, done @rule #412
    - account.analytic.line #421 and #422, done @rule #420
    - financing.contract.format #450, done @rule @451
    - financing.contract.format.line #457, done @rule #452
    - supplier.catalogue #655, done @rule #650
    - supplier.catalogue.line #656, done @rule #655

Show diffs side-by-side

added added

removed removed

Lines of Context:
109
109
                # US-386: Check if file/path exists and raise exception, no need to prepare the backup, thus no pg_dump is executed
110
110
                outfile = os.path.join(bck.name, "%s-%s%s-%s.dump" % (cr.dbname, datetime.now().strftime("%Y%m%d-%H%M%S"), suffix, get_server_version()))
111
111
                bkpfile = open(outfile,"wb")
 
112
                bkpfile.close()
112
113
            except Exception, e:
113
114
                # If there is exception with the opening of the file
114
115
                if isinstance(e, IOError):
118
119
                self._logger.exception('Cannot perform the backup %s' % error)
119
120
                raise osv.except_osv(_('Error! Cannot perform the backup'), error)
120
121
 
121
 
            cmd = ['pg_dump', '--format=c', '--no-owner']
 
122
            cmd = ['pg_dump', '--format=c', '--no-owner', '-f', outfile]
122
123
            if tools.config['db_user']:
123
124
                cmd.append('--username=' + tools.config['db_user'])
124
125
            if tools.config['db_host']:
127
128
                cmd.append('--port=' + str(tools.config['db_port']))
128
129
            cmd.append(cr.dbname)
129
130
 
130
 
            stdin, stdout = tools.exec_pg_command_pipe(*tuple(cmd))
131
 
            stdin.close()
132
 
            data = stdout.read()
133
 
            res = stdout.close()
 
131
            res = tools.exec_pg_command(*tuple(cmd))
134
132
            if res:
135
133
                raise Exception, "Couldn't dump database"
136
134
            self._unset_pg_psw_env_var()
137
 
            bkpfile.write(data)
138
 
            bkpfile.close()
139
135
            return "Backup done"
140
136
        raise Exception, "No backup defined"
141
137