author | Aurelien Campeas <aurelien.campeas@logilab.fr> |
Tue, 25 Jun 2013 12:11:42 +0200 | |
changeset 9148 | 1b549c1acd4f |
parent 8900 | 010a59e12d89 |
child 10366 | 38c7598b5c61 |
permissions | -rw-r--r-- |
7917
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
1 |
"""turn a pyro source into a datafeed source |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
2 |
|
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
3 |
Once this script is run, execute c-c db-check to cleanup relation tables. |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
4 |
""" |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
5 |
import sys |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
6 |
|
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
7 |
try: |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
8 |
source_name, = __args__ |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
9 |
source = repo.sources_by_uri[source_name] |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
10 |
except ValueError: |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
11 |
print('you should specify the source name as script argument (i.e. after --' |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
12 |
' on the command line)') |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
13 |
sys.exit(1) |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
14 |
except KeyError: |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
15 |
print '%s is not an active source' % source_name |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
16 |
sys.exit(1) |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
17 |
|
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
18 |
# check source is reachable before doing anything |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
19 |
try: |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
20 |
source.get_connection()._repo |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
21 |
except AttributeError: |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
22 |
print '%s is not reachable. Fix this before running this script' % source_name |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
23 |
sys.exit(1) |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
24 |
|
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
25 |
raw_input('Ensure you have shutdown all instances of this application before continuing.' |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
26 |
' Type enter when ready.') |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
27 |
|
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
28 |
system_source = repo.system_source |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
29 |
|
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
30 |
from base64 import b64encode |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
31 |
from cubicweb.server.edition import EditedEntity |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
32 |
|
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
33 |
DONT_GET_BACK_ETYPES = set(( # XXX edit as desired |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
34 |
'State', |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
35 |
'RecipeStep', 'RecipeStepInput', 'RecipeStepOutput', |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
36 |
'RecipeTransition', 'RecipeTransitionCondition', |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
37 |
'NarvalConditionExpression', 'Recipe', |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
38 |
# XXX TestConfig |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
39 |
)) |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
40 |
|
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
41 |
|
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
42 |
session.mode = 'write' # hold on the connections set |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
43 |
|
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
44 |
print '******************** backport entity content ***************************' |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
45 |
|
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
46 |
from cubicweb.server import debugged |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
47 |
todelete = {} |
8008
9489dc9bc114
check entity's cwuri and remove debug
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7917
diff
changeset
|
48 |
host = source.config['base-url'].split('://')[1] |
7917
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
49 |
for entity in rql('Any X WHERE X cw_source S, S eid %(s)s', {'s': source.eid}).entities(): |
8900
010a59e12d89
use cw_etype instead of __regid__
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8696
diff
changeset
|
50 |
etype = entity.cw_etype |
7917
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
51 |
if not source.support_entity(etype): |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
52 |
print "source doesn't support %s, delete %s" % (etype, entity.eid) |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
53 |
elif etype in DONT_GET_BACK_ETYPES: |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
54 |
print 'ignore %s, delete %s' % (etype, entity.eid) |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
55 |
else: |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
56 |
try: |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
57 |
entity.complete() |
8008
9489dc9bc114
check entity's cwuri and remove debug
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7917
diff
changeset
|
58 |
if not host in entity.cwuri: |
9489dc9bc114
check entity's cwuri and remove debug
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7917
diff
changeset
|
59 |
print 'SKIP foreign entity', entity.cwuri, source.config['base-url'] |
9489dc9bc114
check entity's cwuri and remove debug
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7917
diff
changeset
|
60 |
continue |
9489dc9bc114
check entity's cwuri and remove debug
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
7917
diff
changeset
|
61 |
except Exception: |
7917
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
62 |
print '%s %s much probably deleted, delete it (extid %s)' % ( |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
63 |
etype, entity.eid, entity.cw_metainformation()['extid']) |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
64 |
else: |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
65 |
print 'get back', etype, entity.eid |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
66 |
entity.cw_edited = EditedEntity(entity, **entity.cw_attr_cache) |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
67 |
system_source.add_entity(session, entity) |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
68 |
sql("UPDATE entities SET asource=%(asource)s, source='system', extid=%(extid)s " |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
69 |
"WHERE eid=%(eid)s", {'asource': source_name, |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
70 |
'extid': b64encode(entity.cwuri), |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
71 |
'eid': entity.eid}) |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
72 |
continue |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
73 |
todelete.setdefault(etype, []).append(entity) |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
74 |
|
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
75 |
# only cleanup entities table, remaining stuff should be cleaned by a c-c |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
76 |
# db-check to be run after this script |
8696
0bb18407c053
[toward py3k] rewrite dict.keys() and dict.values() (part of #2711624)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
8008
diff
changeset
|
77 |
for entities in todelete.itervalues(): |
7917
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
78 |
system_source.delete_info_multi(session, entities, source_name) |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
79 |
|
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
80 |
|
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
81 |
print '******************** backport mapping **********************************' |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
82 |
session.disable_hook_categories('cw.sources') |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
83 |
mapping = [] |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
84 |
for mappart in rql('Any X,SCH WHERE X cw_schema SCH, X cw_for_source S, S eid %(s)s', |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
85 |
{'s': source.eid}).entities(): |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
86 |
schemaent = mappart.cw_schema[0] |
8900
010a59e12d89
use cw_etype instead of __regid__
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8696
diff
changeset
|
87 |
if schemaent.cw_etype != 'CWEType': |
010a59e12d89
use cw_etype instead of __regid__
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
8696
diff
changeset
|
88 |
assert schemaent.cw_etype == 'CWRType' |
7917
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
89 |
sch = schema._eid_index[schemaent.eid] |
8696
0bb18407c053
[toward py3k] rewrite dict.keys() and dict.values() (part of #2711624)
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
8008
diff
changeset
|
90 |
for rdef in sch.rdefs.itervalues(): |
7917
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
91 |
if not source.support_entity(rdef.subject) \ |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
92 |
or not source.support_entity(rdef.object): |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
93 |
continue |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
94 |
if rdef.subject in DONT_GET_BACK_ETYPES \ |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
95 |
and rdef.object in DONT_GET_BACK_ETYPES: |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
96 |
print 'dont map', rdef |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
97 |
continue |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
98 |
if rdef.subject in DONT_GET_BACK_ETYPES: |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
99 |
options = u'action=link\nlinkattr=name' |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
100 |
roles = 'object', |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
101 |
elif rdef.object in DONT_GET_BACK_ETYPES: |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
102 |
options = u'action=link\nlinkattr=name' |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
103 |
roles = 'subject', |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
104 |
else: |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
105 |
options = u'action=copy' |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
106 |
if rdef.rtype in ('use_environment',): |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
107 |
roles = 'object', |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
108 |
else: |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
109 |
roles = 'subject', |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
110 |
print 'map', rdef, options, roles |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
111 |
for role in roles: |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
112 |
mapping.append( ( |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
113 |
(str(rdef.subject), str(rdef.rtype), str(rdef.object)), |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
114 |
options + '\nrole=%s' % role) ) |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
115 |
mappart.cw_delete() |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
116 |
|
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
117 |
source_ent = rql('CWSource S WHERE S eid %(s)s', {'s': source.eid}).get_entity(0, 0) |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
118 |
source_ent.init_mapping(mapping) |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
119 |
|
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
120 |
# change source properties |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
121 |
config = u'''synchronize=yes |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
122 |
synchronization-interval=10min |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
123 |
delete-entities=no |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
124 |
''' |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
125 |
rql('SET X type "datafeed", X parser "cw.entityxml", X url %(url)s, X config %(config)s ' |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
126 |
'WHERE X eid %(x)s', |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
127 |
{'x': source.eid, 'config': config, |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
128 |
'url': source.config['base-url']+'/project'}) |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
129 |
|
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
130 |
|
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
131 |
commit() |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
132 |
|
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
133 |
from cubes.apycot import recipes |
436400e7f807
sample script to turn a pyro source into a datafeed source
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
134 |
recipes.create_quick_recipe(session) |