~vauxoo/addons-vauxoo/7.0-extrae-adjuntos-dev-yzk

« back to all changes in this revision

Viewing changes to openacademy/xml-rpc/misc/obtiene_attach_pdf.py

  • Committer: Isaac López
  • Date: 2013-08-28 23:31:42 UTC
  • Revision ID: isaac@vauxoo.com-20130828233142-jhinudluv4lp6hcn
[ADD] scripts get attachment

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- encoding: utf-8 -*-
 
2
import time
 
3
import base64
 
4
import xmlrpclib
 
5
 
 
6
from psycopg2 import connect
 
7
 
 
8
conexion=connect("dbname=GBW_1_junio host=127.0.0.1 port=5432 user=gbw password=1234")
 
9
cr=conexion.cursor()
 
10
print 'cr',cr
 
11
 
 
12
cr.execute("""SELECT a.internal_number, i.db_datas, i.datas_fname from ir_attachment i, account_invoice a
 
13
where i.file_type<> 'application/xml' and i.res_model ='account.invoice' 
 
14
and i.db_datas is not NULL and a.id = i.res_id
 
15
""")
 
16
dat=cr.fetchall()
 
17
print 'dat',dat
 
18
count = 0
 
19
for d in dat:
 
20
    string_pdf =d[1]
 
21
    print '-----------file name',d[2]
 
22
    file_name = '/home/yzaack/instancias/6.0/server/bin/filestore/GBW_1_junio/mjfZwqOqgL/%s' % d[2]
 
23
    file_pdf = open(file_name,'wb')
 
24
    file_pdf.write(string_pdf)
 
25
    file_pdf.close()
 
26
    count +=1
 
27
print '-------el total de PDF generados',count