16 |
# write to the Free Software Foundation, Inc., 59 Temple Place |
# write to the Free Software Foundation, Inc., 59 Temple Place |
17 |
# - Suite 330, Boston, MA 02111-1307, USA. |
# - Suite 330, Boston, MA 02111-1307, USA. |
18 |
# |
# |
19 |
# Copyright 2002 Free Software Foundation |
# Copyright 2002-2003 Free Software Foundation |
20 |
# |
# |
21 |
# FILE: |
# FILE: |
22 |
# GIClient.py |
# GIClient.py |
30 |
import os |
import os |
31 |
import sys |
import sys |
32 |
import string |
import string |
33 |
|
from GIParser import loadMapping |
|
from gnue.integrator.GIParser import loadMapping |
|
|
from gnue.integrator import Actions |
|
34 |
from gnue.common import GDebug |
from gnue.common import GDebug |
35 |
from gnue.common.FileUtils import openResource |
from gnue.common.FileUtils import openResource |
36 |
from gnue.common import GDataObjects, GConnections |
from gnue.common import GDataObjects, GConnections |
47 |
COMMAND = "gnue-integrator" |
COMMAND = "gnue-integrator" |
48 |
NAME = "GNUe Integrator" |
NAME = "GNUe Integrator" |
49 |
USAGE = "[options] file" |
USAGE = "[options] file" |
50 |
COMMAND_OPTIONS = [] |
COMMAND_OPTIONS = [ |
51 |
|
[ 'testing','t','testing',1,None,None, |
52 |
|
_("If you set this flag, Integrator won't write any data to ")+ |
53 |
|
_("destination datasources. ")] |
54 |
|
] |
55 |
SUMMARY = \ |
SUMMARY = \ |
56 |
"GNUe Integrator is the data integration/migration tool of the GNU Enterprise system." |
"GNUe Integrator is the data integration/migration tool of the GNU Enterprise system." |
57 |
|
|
74 |
mappingFile = self.ARGUMENTS[0] |
mappingFile = self.ARGUMENTS[0] |
75 |
except: |
except: |
76 |
self.handleStartupError ("No Integrator Definition File Specified.") |
self.handleStartupError ("No Integrator Definition File Specified.") |
77 |
|
|
78 |
|
lh = NoLoginHandler() |
79 |
|
self.getConnectionManager().setLoginHandler(lh) |
80 |
|
|
81 |
fileHandle = openResource(mappingFile) |
fileHandle = openResource(mappingFile) |
82 |
mapping = loadMapping (fileHandle) |
mapping = loadMapping (fileHandle, self.connections) |
83 |
fileHandle.close() |
fileHandle.close() |
84 |
|
|
85 |
|
|
86 |
|
|
87 |
# add connections object to top object |
if self.OPTIONS["testing"]: |
88 |
mapping._connections=self.connections |
mapping._testonly=1 |
89 |
|
|
90 |
|
mapping.run() |
91 |
|
|
92 |
|
# |
93 |
|
# Login handler for --batch mode |
94 |
|
# |
95 |
|
from gnue.common import GLoginHandler |
96 |
|
class NoLoginHandler(GLoginHandler.LoginHandler): |
97 |
|
|
98 |
|
defaults = {'_username': 'jan', '_password': None} |
99 |
|
|
100 |
|
def getLogin(self, loginData, error): |
101 |
|
val = {} |
102 |
|
for prompt in loginData[2]: |
103 |
|
if self.defaults.has_key(prompt[0]) and self.defaults[prompt[0]]: |
104 |
|
val[prompt[0]] = self.defaults[prompt[0]] |
105 |
|
else: |
106 |
|
val[prompt[0]] = None |
107 |
|
return val |
108 |
|
|
109 |
|
def destroyLoginDialog(self): |
110 |
|
pass |
111 |
|
|
112 |
|
|
113 |
|
|