*** dcmwai has quit IRC *** holycow has quit IRC *** rynik has joined #gnuenterprise good morning hi Hi. Can anyone help me with my python, I'm new to it! I have bouth .deb and svn install. Now I wrote this python script and wanted it to import libs from svn. But import is done from .deb (/usr/lib/gnue/python). How can I make it import from svn? s/bouth/both *** yure has joined #gnuenterprise ajmitch, are you there? hi all hi dimas! do you need to import gnue lib? Yes... ...help... if you have svn install, have you tried gcvs? gcvs instead of python hmm, dont remember. What is it? it is a wrapper that helps you get gnue modules in pythonpath Ahh :) That did the trick. Thank you! np, glad it helped :) *** docelic has joined #gnuenterprise is gnue-sb moving along ? *** docelic has quit IRC *** docelic has joined #gnuenterprise *** holycow has joined #gnuenterprise *** holycow has quit IRC *** docelic has quit IRC *** docelic has joined #gnuenterprise *** docelic has quit IRC *** jcater has quit IRC *** docelic has joined #gnuenterprise hi, does anyone here write GClientApp-s? i want to interact with an appserver but i'm lost gnue-appserver/src/test.py is working example thanks I dislike python but Im even ready to forget that, given how nice gnue seems :) docelic: ack *** jcater has joined #gnuenterprise *** jcater has quit IRC *** btami has joined #gnuenterprise mnemoc: Are you still importing dbf to appserver? i'm trying :) What is the problem now? reinhard fixed some bugs on dbffile lastnight rynik: python :) this is the first time i code in python so i'm quite slow Why do you need GClientApp? i'm writing a gClientApp to do the migration there is another waY? i can't inject data because of gnue_id Why dont you just parse the dbf directly from pyton? that's what dbffile does hi all you are trying to write a python script that fills appserver with data, right? yes! let me pepare a kind of sample for that I'd be honored! from gnue.appserver.language.language import App app = App.App () session = app.newSession ('user', 'password') I did this to import: session.new ('kontoplan_plan') err skip last line p = session.new ('kontoplan_plan') p.kontoplan_text = 'foo bar' session.commit() ------ put that in a separate python file and just run i I do: import string from gnue.appserver.language import App filename = 'Catgaze.kp' if filename!="": f=open(filename,'r') tmpstr=f.readline() found=string.find(tmpstr,'#FILTYP KONTO ACP') if found==0: app = App.App () session = app.newSession ('user','password') for line in f: line = line.rstrip('\r\n') tmplist=string.split(line,' ', 1) tmplist[1]=string.strip(tmplist[1],'"') if string.find(tmplist[0],'#TEXT')==0: print(tmplist[1]) plan=session.new( "kontoplan_plan" ) plan.kontoplan_text=unicode(tmplist[1], 'iso-8859-1') session.commit() ah rynik==ryni1 :) right:) :) * btami goes back his hole i guess i'm starting to understand it *** docelic has quit IRC what is default auth method? nothing just leave it as ('user','password') although records will be created by 'user' :) Are you interested in authentication you have to turn it on in gnue.conf and add some records to the gnue db, I dont know the details. i read something about custom_auth = foo I try to remember where I read about auth. I think it was in one of the samples. http://www.gnuenterprise.org/tools/common/docs/technotes/00005.txt ? but it's old gnue/gnue-appserver/samples/README has some answers on auth. nice *** reinhard has joined #gnuenterprise hi reinhard *** yure has quit IRC hi mnemoc bbl *** rynik has left #gnuenterprise *** jcater has joined #gnuenterprise *** cilkay has joined #gnuenterprise *** cilkay has left #gnuenterprise *** rynik has joined #gnuenterprise *** mnemoc_ has joined #gnuenterprise *** mnemoc has quit IRC reinhard: what does this work for? (appserver/src/test.py) def __init__ (self, connections = None): ConfigOptions = geasConfiguration.ConfigOptions GClientApp.__init__ (self, connections, 'appserver', ConfigOptions) i'm getting connections files as argument and i open dbffile connections. can this initialization produce troubles in my case? *** sjc has joined #gnuenterprise seems ok mnemoc: watching tv, in and out in advertising breaks what are you trying to do? migrate from dbf to appserver data migration? you already have your classes defined? mnemoc: you might want to look at appserver/language/test.py might be more useful for what you are trying to do well, hmmm you need an application that is a client to appserver and a client to dbf at the same time, right? sh*t, we *really* need a volunteer to implement gnue-integrator :) :) yeah ... bytewise needs some more developers :) i need to _learn_ python first lol reinhard, well, my son turns 7 in a couple of months I think I can have him corrupted, err, trained by the time he's 12 jcater: lol :) 7 is a good age to learn to code jcater: my daughters are 8 and 9 let's see who can code in python first ;-) mine just 4 and 1 :p lol they both already know basic shell and vi commands haha but they use xfce :) 8 yr old using vi you are one sadistic person haha I was training one of my newest IT guys on vim a couple of months ago back to tv... "So, no one really uses this, right? Why am I learning this?" * mnemoc wonders what internet-generation-hackers' children will do in the future laugh at us :) hopefully write gnue packages ;) by then the tools should be done *** docelic has joined #gnuenterprise haha i hope so :) ouch sad, but true *** yure has joined #gnuenterprise reinhard: what connection is appserver/language/test.py using? outch mnemoc, What's up? appserver.language.App is ungry with the COMMAND_OPTIONS i give to GClientApp What COMMAND_OPTIONS are you talking about? inside my GClientApp class i'm creating that app.App(), but screams about -d option i use if appserver.language.App is a GClientApp, why can't i use it as base for my class? What do you mean with base? 6 #class MigrateDBF(GClientApp): 7 class MigrateDBF(App): when i did app = app.App() inside my MigrateDBF(GClientApp) i got an abort due to my -d option what am i doing wrong? :'( I've mever done it like that, as a class. Why? It seems to be problematic. i don't know python, i just followed the sample on gnue-common's DeveloperGuide class MigrateDBF(App): TypeError: Error when calling the metaclass bases module.__init__() takes at most 2 arguments (3 given) what I pasted befor, starting with import string, that was the start of my python script. I used it to import from a textfile. No classes ok, i'll try without classes do i need the __main__ thing? mnemoc: do you know perl well ? sure or some other script language I've done it in one more way: import sys, os, string from gnue.common.apps import RuntimeSettings, errors from types import * import string import copy import weakref import time from gnue.common.datasources import GDataSource, GConditions, GConnections from gnue.common.utils.uuid import UUID if __name__ == '__main__': from gnue.common.apps import GClientApp from gnue.appserver import geasConfiguration, data app = GClientApp.GClientApp (application = 'appserver', defaults = geasConfiguration.ConfigOptions) print 'create connection object ...', c = data.connection (app.connections, 'cajvta4') That seems to work as well. i'll do it that way and worry about arguments later Probably dont need all the imports though can i have functions without a class? I dont know... i'll try to use helper class then look at: gnue/gnue-appserver/src/data.py Thats were I got the code. Hope I dont just mess things up for you. I'm new to python to. i hope to pass this panic phase soon, and start understanding it asap reinhard: what connection app.newSession() connects? NotFoundError: The connections file does not contain a definition for "gnue" gnue :) Hmm. I would have thought it would connect to appserver... but no i had it as 'appserver' context==module? how large is the svn repository ? $ du -sh . 82M . aha.. not something to do over a modem right now ;-) plus 14 MB for subversion and company itself i could tar it for you, but i am a bit distant no no , I'll be back to my "worksite" in few days thanks np :) mnemoc, What approach do you have now? appserver.language.app, what reinhard suggested without classes, as you suggested like: app = App.App () session = app.newSession ('user','password')? yes but session.setContext.... what is that? module name? how is your .dbf files arranged let me see :) uhm... i missunderstood you... what do you mean by 'arranged'? ordered? Are they tab separated entries. nope, .dbf :) i have some .csv also, but that is another story i'm using DataSourceWrapper to loop over them I thought .dbf was tab separated plain text Because with your current approch you will have to pars the file in python and put it in appserver manualy. s/pars/parse DataSourceWrapper let me loop and use fields Is that a gnue-common yes the sample on DevelopersGuide use it I'm not sure but I think you mix things up. With the approach you have taken you don't have anny 'connection' to the .dbf file. You just read it plain text. .oO With the other approach you get an connection though: app = GClientApp.GClientApp (application = 'appserver', defaults = rynik geasConfiguration.ConfigOptions) rynik print 'create connection object ...', rynik c = data.connection (app.connections, 'cajvta4') dbfCliente = DataSourceWrapper( app.connections, fields = [ 'CLIRUT', 'CLINOM' ], attributes = { 'connection': 'dat_cli', 'name': 'dat_cli', } ) dbfClienteSet = dbfCliente.createResultSet() for record in dbfClienteSet: print record['CLIRUT'], record['CLINOM'] that is working i'm trying now to find a client with record['CLIRUT'] as 'rut' if i find him i need to udate it's 'name' acording to 'nom' else, create it just a simple sample to learn :) Seems your well on your way. am i too lost? What? I said you'r well on your way. You have a connection open to your .dbf files and another to the appserver. Should just be a matter of shoveling the data over to the appserver then. Unless your doing a lot of manipulation on the way. i don't understand how to use the session What session? The one opened to the appserver? yes i can't focus :( ... to much stress damn deadlines and english and python are not natural to me :) Once you have the session you can do: p=session.new( "mymodule_myclass" ) what setcontext does? and you have a new record of the class mymodule_myclass reinhard use it on appserver/language/test.py rynik: and uuid? when should i set it? gnue_id i mean You dont have to yse setcontext but hte adressing gets different gnue_id gets set by it self once you have p (above) you can do p.mymodule_myproperty=unicode('textstring', 'iso-8859-1') That is assigning a value to the property 'myproperty' of the class 'myclass' it is not finding my class but i see it on postgres Where or when is it not finding your class *** reinhard has quit IRC ModuleNotFoundError: Module 'cliente' not found in class repository. on: clientes = appserver.find('cliente_cliente') appserver is the session can i list the classes the session think i have? :( I dont know I dont find any documentation on that Should be appserver spcific I suppose. Why do you do appserver.find('cliente_cliente') And not appserver.new('cliente_cliente') uhm have you done the .gcd file and imported it with gnue-readgcd and restarted the appserver? sure i'll try creating instances blindly same thing * mnemoc wonder what gnue-appserver is doing when i do requests... there is some trace mode on python? strace python gives a bit to much output * mnemoc wants to scream mnemoc: strace -e trace=<...> *** btami has left #gnuenterprise i just noticed it is system DB000: File "/opt/gnue/lib/python2.4/site-packages/gnue/appserver/classrep/Base.py", line 290, in __getitem__ DB000: raise self._itemNotFoundError (key) gnue which is raising the error weird considering i'm using dbffile (which is svn only) on connections.conf and system gnue is 0.5.14 i'll remove that bast* uhm... i cant running gnue-appserver is on system :p docelic: what inside trace=<...>? When you run your script do you use 'gcvs script.py' instead of 'python script.py'? app: (111, 'Connection refused') ... at least i know it connects to the right server rynik: python, but PYTHONPATH= set mnemoc: what do you want to get from strace? files it is opening ? docelic: actually nothing.... modules and classes, a thing i can't see using strace :\ docelic: i'm puzzled mnemoc: try ltrace , for library calls mnemoc: although python-system should be better in this case than a general-purpose trace docelic: python-system? https://developer.berlios.de/projects/pythonsystem/ <-- this? rynik: that was! rynik: thanks for the gcvs thing mnemoc: no, I mean, python way to track module loads exporting PYTHONPATH= wasn't enough docelic: oh rynik: how do i set a condition for session.find() ? I don't know but why do you whant to find? Just shovel your data in there. because i can have duplications.... for record in dbfClienteSet: nuevoCliente = appserver.new('cliente_cliente') nuevoCliente.cliente_rut = record['CLIRUT'] print record['CLIRUT'], record['CLINOM'] why that is damaging the content of record['CLIRUT'] ? the field is called 'rut' but nuevoCliente.rut fails so i used what i saw on the database nuevoCliente.cliente_rut looks good but printed stuff changes if i assign record['CLIRUT'] to nuevoCliente.cliente_rut uhm Changes in what way in fact it change with nuevoCliente = appserver.new('cliente_cliente') with bouth nuevoCliente lines commented i get: 13240886 CIFUENTES ALEGRE BIANCA E uncommenting the line which does the 'new' 003584022 CIFUENTES ALEGRE BIANCA E uhm it gets corrupted after reading it damn... i understand nothing unicode(record['CLIRUT']) wouldnt change it but might be a good idé? CLIRUT is an integer OK sry i'll use it for the name anyway ;) Is 003584022 the post after 13240886 no, looks like a shored memory address absolulty out of busyness context even this fail: for record in dbfClienteSet: rut, nombre = record['CLIRUT'], record['CLINOM'] print rut, nombre nuevoCliente = appserver.new('cliente_cliente') print rut, nombre, nuevoCliente it's very weird to see it damage data which suppose to be already printed Very wierd... btw can U print nuevoCliente 11d9b9caf9afdd289e4100055d771774 Oh, It prints the gnue_id yep :) how can i convert an string into a number? how can i know the type of a var? string to number int(string) import what? built in I think session.new() is very slow doesn't it cache class data? Hm, lets save that question for reinhart. :) :) so, i have to: object = session.new('module_class') object.class_field = foo object.commit() ? No, object.module_field = foo oh Same thing though in your case. in this case only :) what about find? how can i request an object of a class when field=foo ? object = session.find('module_class', .... ) how do i define a condition? I dont know, I'll do some experiments... conditions - condition which must be matched. This could be a dictionary, a sequence in prefix notation or a GCondition tree this is chinese to me 4427275 NU¤EZ FLORES JUAN S. DB000: ProtocolError: outch trying with unicode() now DB000: UnicodeDecodeError: 'ascii' codec can't decode byte 0xa4 in position 2: ordinal not in range(128) unicode(record['CLIRUT'], 'iso-8859-1') i'm testing with 'encoding = ascii' on dbf connection... now with yours looking good sloooooow but good I found this in the API reference: list_id=appserver.request (appserver, "cliente_cliente",conditions, sortorder, properties) could that be of interest? looks identical to find I dont find docs on find Anyway, the problem is what goes in conditions, sortorder, properties - right? yes considering our fields are 'virtual' and conditions should apply to any record i would do a tree [ 'op', 'field', 'value' ] but.... i can't find any sample :'( i'll do some grep rynik: what do you use for python reference? http://www.python.org/doc/2.3.5/lib/lib.html oh anything more basic? 'just the amount of python stuff you need to do something simple'? *** dsmith has joined #gnuenterprise chillywilly: Hey, did you ever get your docbook stuff figured out? http://www.python.org/doc/2.3.5/tut/tut.html thanks :) gnue/common/datasources/GConditions.py: 'ParentTags': ('conditions','and','or','not','negate'), Hey, the website looks great btw. *** sjc has quit IRC conditions = {'gnue_id': filterValue} let's try sortorder = [] properties = ['gnue_id'] DB000: cliente = appserver.request('client', {'rut': rut }) DB000: AttributeError: LoginSession instance has no attribute 'request' pff try find then i got a match! DB000: print "%s is already here! at %s" % rut % cliente DB000: TypeError: not enough arguments for format string how do i print the second arg? rut, cliente ? sortorder = [] properties = ['gnue_id'] i mean, on the print :) not comma print "%s is already here! at %s" % (rut,cliente) cliente[1]? thanks python is not that ugly when you start knowing it I think it's beautiful. perl is beautiful :) i need my tab back :( Dont know perl. I come from ADA, C, Haskell Haskell! Something I must learn someday. :) :) It's wierd before you get into it. like python .oO( this loop is slow as hell )o Like python if you had to write everything backwards. o_O When I did my import i acctualy thought something was wrong. But eventualy it exited. print is my friend now :) i have to import 23 tables of 72 monthes :( Is it roling now? my test seems to be working but i have to wait until it reach the commit Is that only one table? two fields of one table :p When is your deadline? two days ago How is it going? bad :( ? my learning curve has not been my best Why, What, did you reach commit? not yet but it's moving You should be thinking of a way to automate the rest of the work and go to sleep. I mean do you know how to iterate over all the files? i have generated a YYYY-MM/connections.conf file and a Makefile will do the rest in fact Makefile calls connections.conf generator also now i hope to only need to write the migration code i draw Don't understand but you seems to have it figured out :) and learning how to parse text to achieve that sorry, my english stinks Italian? what part doesn't fit you? chilean fit? .oO( do i write english like italian people? )o match what is wrong on my plan? Probably nothing, I don't know the magic of Makefiles. I was seeing a for-loop over YYYY and MM i have my 72 backups on YYYY-MM.tar.bz2 YYYY=year, MM=month using a Makefile i look for a dir called YYYY-MM/ based on .tar.bz2 file list if missing i untar and clean then i look for YYYY-MM/connections.conf if not found, i call a bash script which writes a the file with a connection for the appserver and one connection for every dbf and finally i look for YYYY-MM/done if not, i call this python script i'm writing, with that connections.conf Aha, now I see. I thought you had one great connections.conf with all the connections. that would make my script more difficult true No, I should be of to bed! It's 2.20 here and my family will wake me up in a couple of hours. Good luck mnemoc! and good night all gn8 and thanks a lot rynik my pleasure:) :) *** docelic has quit IRC *** jcater has quit IRC *** dsmith has quit IRC