[Tutor] Application packaging

2011-09-05 Thread Carlos Daniel Ruvalcaba Valenzuela
Hello list,

Lately I have been working on a windows desktop application for a client,
using python and pyside, everything working fine, but I'm getting a bit
stuck when trying to distribute the application to the client.

Currently I'm using a combination of py2exe and clickonce, what are your
experiences on distributing this kind of applications on a windows
environment?

Personally I have tried py2exe, pyinstaller, cx_freeze, only py2exe got me a
working bundle but a ugly one full of unordered files, I wrapped all this on
a ClickOnce installer so the user just sees an icon in their desktop. The
problem with this approach is that it results in a huge bundle, updates are
a pain too. Any ideas or experience with this (not precisely this combo but
the packaging in general)?

Regards,
Carlos Ruvalcaba

PD: I'm looking for the actual state of things right now as I'm sure this
questing has been asked in the past.
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] 'function' object has no attribute 'writer'

2011-09-05 Thread Peter Otten
Susana Iraiis Delgado Rodriguez wrote:

Susana, please use 4-space indents for your code samples. I've said it 
before, but I think it's worthwhile repeating because it makes it much 
easier to grasp the structure of a script at first sight.

> But now I get a differente error, this script is going to collect
> information from shapefiles, I asked the user where to start the search,
> the file extension, and the csv name. Now I get:
 import win
 Seleccione directorio donde empezar
> You chose C:/
> Escribe la extension que necesitas buscar
> Buscando archivos:  .shp
> Nombre del csv a crear
> Archivo de salidad:  gui.csv
> Iniciando...
> Exception in Tkinter callback
> Traceback (most recent call last):
>   File "C:\Python26\lib\lib-tk\Tkinter.py", line 1410, in __call__
> return self.func(*args)
>   File "win.py", line 65, in boton4
> shapeData = ogr.Open(filepath)
>   File "C:\Python26\lib\site-packages\osgeo\ogr.py", line 4033, in Open
> return _ogr.Open(*args, **kwargs)
> TypeError: in method 'Open', argument 1 of type 'char const *'
> 
> The other part of the code is:

> from osgeo import ogr,gdal,osr

>   shapeData = ogr.Open(filepath)

filepath is a unicode string, your library seems to expect byte strings.
Try converting it like so:

import sys
filesystemencoding = sys.getfilesystemencoding()
#...
shapeData = ogr.Open(filepath.encode(filesystemencoding))

___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] 'function' object has no attribute 'writer'

2011-09-05 Thread Susana Iraiis Delgado Rodriguez
Hello guys!!!
Shame on me, you're rigth I missunderstood the function and the module.
I change the name of my function and that part of my code worked.
But now I get a differente error, this script is going to collect
information from shapefiles, I asked the user where to start the search, the
file extension, and the csv name. Now I get:
>>> import win
>>> Seleccione directorio donde empezar
You chose C:/
Escribe la extension que necesitas buscar
Buscando archivos:  .shp
Nombre del csv a crear
Archivo de salidad:  gui.csv
Iniciando...
Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Python26\lib\lib-tk\Tkinter.py", line 1410, in __call__
return self.func(*args)
  File "win.py", line 65, in boton4
shapeData = ogr.Open(filepath)
  File "C:\Python26\lib\site-packages\osgeo\ogr.py", line 4033, in Open
return _ogr.Open(*args, **kwargs)
TypeError: in method 'Open', argument 1 of type 'char const *'

The other part of the code is:
from Tkinter import * #Llamo las librerias graficas de Tk
import tkSimpleDialog #Libreria de almacenamiento de dialogos
import tkMessageBox #Libreria de mensajes
import tkFileDialog
import sys, os, csv, time, socket, stat
from osgeo import ogr,gdal,osr
from osgeo.gdalconst import *
from PIL import Image
dir = ""
extn = ""
csv_name = ""

def directorio():
 global dir
 print 'Seleccione directorio donde empezar'
 dirname =
tkFileDialog.askdirectory(parent=root,initialdir="/",title='Selecciona la
ruta a escanear')
 if len(dirname ) > 0:
  print "You chose %s" % dirname
 dir = dirname
def extension():
 global extn
 print "Escribe la extension que necesitas buscar"
 ext=tkSimpleDialog.askstring('Extension a buscar:','')
 print 'Buscando archivos: ',ext
 extn = ext
def csv_w():
 global csv_name
 print "Nombre del csv a crear"
 inv=tkSimpleDialog.askstring('Nombre de .csv:','')
 print 'Archivo de salidad: ',inv
 csv_name = inv
def boton4():
 print 'Iniciando...'
 gdal.AllRegister()
 file_list = []
 folders = None
 for root, folders, files in os.walk(dir):
  file_list.extend(os.path.join(root,fi) for fi in files if
fi.endswith(extn))
 f = open(csv_name, 'wb')
 log = open ('log_errores.txt','w')
 writer = csv.writer(f)
 ruta = 'Ruta'
 archivo = 'archivo'
 x_min = 'x_min'
 x_max = 'x_max'
 y_min = 'y_min'
 y_max = 'y_max'
 geometria = 'geometria'
 num_elem = 'num_elem'
 prj = '.prj'
 proyeccion = 'proyeccion'
 fecha = 'fecha_modificacion'
 creacion = 'fecha_creacion'
 ultimo = 'ultimo_acceso'
 tamanio = 'tamanio_aprox'
 maq = 'maquina_host'
 usu = 'usuario'
 campos =
[ruta,archivo,x_min,x_max,y_min,y_max,geometria,num_elem,prj,proyeccion,creacion,fecha,ultimo,tamanio,maq,usu]
 writer.writerow(campos)
 for row, filepath in enumerate(file_list, start=1):
  directorio = os.path.dirname(filepath)
  filename = os.path.basename(filepath)
  shapeData = ogr.Open(filepath)
  shp = 'Error al abrir el archivo' +filepath
  if shapeData is None:
   print shp
   log.write(shp+"\n")
2011/9/5 James Reynolds 

>
>
>   On Mon, Sep 5, 2011 at 12:08 PM, Susana Iraiis Delgado Rodriguez <
> susana.delgad...@utzmg.edu.mx> wrote:
>
>>   I want to write a csv file, but I need the final user to give me some
>> values to open and update the file. My code is:
>> from Tkinter import * #Llamo las librerias graficas de Tk
>> import tkSimpleDialog #Libreria de almacenamiento de dialogos
>> import tkMessageBox #Libreria de mensajes
>> import tkFileDialog
>> import sys, os, csv, time, socket, stat
>> from osgeo import ogr,gdal,osr
>> from osgeo.gdalconst import *
>> from PIL import Image
>> dir = ""
>> extn = ""
>> csv_name = ""
>> def directorio():
>>  global dir
>>  print 'Seleccione directorio donde empezar'
>>  dirname =
>> tkFileDialog.askdirectory(parent=root,initialdir="/",title='Selecciona la
>> ruta a escanear')
>>  if len(dirname ) > 0:
>>   print "You chose %s" % dirname
>>  dir = dirname
>> def extension():
>>  global extn
>>  print "Escribe la extension que necesitas buscar"
>>  ext=tkSimpleDialog.askstring('Extension a buscar:','')
>>  print 'Buscando archivos: ',ext
>>  extn = ext
>> def csv():
>>  global csv_name
>>  print "Nombre del csv a crear"
>>  inv=tkSimpleDialog.askstring('Nombre de .csv:','')
>>  print 'Archivo de salidad: ',inv
>>  csv_name = inv
>> def boton4():
>>  print 'Iniciando...'
>>  gdal.AllRegister()
>>  file_list = []
>>  folders = None
>>  for root, folders, files in os.walk(dir):
>>   file_list.extend(os.path.join(root,fi) for fi in files if
>> fi.endswith(extn))
>>  f = open(csv_name, 'wb')
>>  log = open ('log_errores.txt','w')
>>  writer = csv.writer(f)
>> ... more code
>> But when I run it,console shows:
>> Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 b
>> win32
>> Type "help", "copyright", "credits" or "license" for more informa
>> >>> import win
>> >>> Seleccione directorio donde empezar
>> You chose C:/
>> Escribe la extension que necesitas buscar
>> Buscando archivos:  .shp
>> Nombre del csv a crear
>> Archivo de salidad: 

Re: [Tutor] 'function' object has no attribute 'writer'

2011-09-05 Thread Walter Prins
Hi Susana,

On 5 September 2011 17:08, Susana Iraiis Delgado Rodriguez <
susana.delgad...@utzmg.edu.mx> wrote:

>   File "win.py", line 43, in boton4
> writer = csv.writer(open(csv_name, 'w'))
> AttributeError: 'function' object has no attribute 'writer'
> I read a tutorial and csv has a writer function, I'm lost
>
>
Yes, the csv module has a writer function.  But read carefully!  The error
message isn't saying that the csv module doesn't have a writer function --
it says **function object** has no attribute 'writer'.  So... somehow Python
thinks that the name 'csv' refers to a function at the point in the code
where the error is thrown.  So how can this be?  You should be asking
yourself this question -- could it be that you've (for example) defined a
*function* called 'csv', thereby effectively effectively hiding the *module*
csv?  ;)

Walter
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] 'function' object has no attribute 'writer'

2011-09-05 Thread James Reynolds
On Mon, Sep 5, 2011 at 12:08 PM, Susana Iraiis Delgado Rodriguez <
susana.delgad...@utzmg.edu.mx> wrote:

> I want to write a csv file, but I need the final user to give me some
> values to open and update the file. My code is:
> from Tkinter import * #Llamo las librerias graficas de Tk
> import tkSimpleDialog #Libreria de almacenamiento de dialogos
> import tkMessageBox #Libreria de mensajes
> import tkFileDialog
> import sys, os, csv, time, socket, stat
> from osgeo import ogr,gdal,osr
> from osgeo.gdalconst import *
> from PIL import Image
> dir = ""
> extn = ""
> csv_name = ""
> def directorio():
>  global dir
>  print 'Seleccione directorio donde empezar'
>  dirname =
> tkFileDialog.askdirectory(parent=root,initialdir="/",title='Selecciona la
> ruta a escanear')
>  if len(dirname ) > 0:
>   print "You chose %s" % dirname
>  dir = dirname
> def extension():
>  global extn
>  print "Escribe la extension que necesitas buscar"
>  ext=tkSimpleDialog.askstring('Extension a buscar:','')
>  print 'Buscando archivos: ',ext
>  extn = ext
> def csv():
>  global csv_name
>  print "Nombre del csv a crear"
>  inv=tkSimpleDialog.askstring('Nombre de .csv:','')
>  print 'Archivo de salidad: ',inv
>  csv_name = inv
> def boton4():
>  print 'Iniciando...'
>  gdal.AllRegister()
>  file_list = []
>  folders = None
>  for root, folders, files in os.walk(dir):
>   file_list.extend(os.path.join(root,fi) for fi in files if
> fi.endswith(extn))
>  f = open(csv_name, 'wb')
>  log = open ('log_errores.txt','w')
>  writer = csv.writer(f)
> ... more code
> But when I run it,console shows:
> Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 b
> win32
> Type "help", "copyright", "credits" or "license" for more informa
> >>> import win
> >>> Seleccione directorio donde empezar
> You chose C:/
> Escribe la extension que necesitas buscar
> Buscando archivos:  .shp
> Nombre del csv a crear
> Archivo de salidad:  gui.csv
> Iniciando...
> Exception in Tkinter callback
> Traceback (most recent call last):
>   File "C:\Python26\lib\lib-tk\Tkinter.py", line 1410, in __call_
> return self.func(*args)
>   File "win.py", line 43, in boton4
> writer = csv.writer(open(csv_name, 'w'))
> AttributeError: 'function' object has no attribute 'writer'
> I read a tutorial and csv has a writer function, I'm lost
>
> ___
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
>


You have a function called "csv()" in your code.

So when you go csv.blahbittyblob, you've overriden your imported module
called "csv" with the function called "csv", python then tries to look up
the attribute blahbittyblob and can't find it. it then throws an error.

Change your csv function to be csvx() or _csv or something other than csv
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


[Tutor] 'function' object has no attribute 'writer'

2011-09-05 Thread Susana Iraiis Delgado Rodriguez
I want to write a csv file, but I need the final user to give me some values
to open and update the file. My code is:
from Tkinter import * #Llamo las librerias graficas de Tk
import tkSimpleDialog #Libreria de almacenamiento de dialogos
import tkMessageBox #Libreria de mensajes
import tkFileDialog
import sys, os, csv, time, socket, stat
from osgeo import ogr,gdal,osr
from osgeo.gdalconst import *
from PIL import Image
dir = ""
extn = ""
csv_name = ""
def directorio():
 global dir
 print 'Seleccione directorio donde empezar'
 dirname =
tkFileDialog.askdirectory(parent=root,initialdir="/",title='Selecciona la
ruta a escanear')
 if len(dirname ) > 0:
  print "You chose %s" % dirname
 dir = dirname
def extension():
 global extn
 print "Escribe la extension que necesitas buscar"
 ext=tkSimpleDialog.askstring('Extension a buscar:','')
 print 'Buscando archivos: ',ext
 extn = ext
def csv():
 global csv_name
 print "Nombre del csv a crear"
 inv=tkSimpleDialog.askstring('Nombre de .csv:','')
 print 'Archivo de salidad: ',inv
 csv_name = inv
def boton4():
 print 'Iniciando...'
 gdal.AllRegister()
 file_list = []
 folders = None
 for root, folders, files in os.walk(dir):
  file_list.extend(os.path.join(root,fi) for fi in files if
fi.endswith(extn))
 f = open(csv_name, 'wb')
 log = open ('log_errores.txt','w')
 writer = csv.writer(f)
... more code
But when I run it,console shows:
Python 2.6.6 (r266:84297, Aug 24 2010, 18:46:32) [MSC v.1500 32 b
win32
Type "help", "copyright", "credits" or "license" for more informa
>>> import win
>>> Seleccione directorio donde empezar
You chose C:/
Escribe la extension que necesitas buscar
Buscando archivos:  .shp
Nombre del csv a crear
Archivo de salidad:  gui.csv
Iniciando...
Exception in Tkinter callback
Traceback (most recent call last):
  File "C:\Python26\lib\lib-tk\Tkinter.py", line 1410, in __call_
return self.func(*args)
  File "win.py", line 43, in boton4
writer = csv.writer(open(csv_name, 'w'))
AttributeError: 'function' object has no attribute 'writer'
I read a tutorial and csv has a writer function, I'm lost
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Getting values from different functions (def's)

2011-09-05 Thread Susana Iraiis Delgado Rodriguez
Hello Alan!!
It is exactly what I need to complete my task :D
Than you so much
2011/8/31 Alan Gauld 

> On 31/08/11 18:17, Susana Iraiis Delgado Rodriguez wrote:
>
>> Hello list !!
>> I'm developing a Python GUI application. I alreday developed a very
>> simple window with buttons, each button will do a different task, but
>> the most important button will need to get information gotten in
>> previous python's functions. Let's say I have four functions but at the
>> end I want to collet all the information gotten.
>>
>
> Instead of (or as well as) printing the data you will need to store it in
> variables. Then you can use those variables in the other function.
>
>
>
> from Tkinter import *
>> import tkSimpleDialog
>> import tkMessageBox
>> import tkFileDialog
>>
>
> # define storage variables
> dir = ""
> extn = ""
> csv_name = ""
>
> def directorio():
>>
>global dir# need to specify the global one
>
>
>  print 'Seleccione directorio donde empezar'
>>  dirname = > tkFileDialog.askdirectory(**parent=root,
>>
>   initialdir="/",
>   title='Selecciona > la ruta a escanear')
>
>>  if len(dirname ) > 0:
>>   print "You chose %s" % dirname
>>
>
> dir = dirname  # store the value
>
> def extension():
>>
>global extn
>
>  print "Escribe la extension que necesitas buscar"
>>  ext=tkSimpleDialog.askstring('**Extension a buscar:','')
>>  print 'Buscando archivos: ',ext
>>
>extn = ext
>
> def csv():
>>
>global csv_name
>
>  print "Nombre del csv a crear"
>>  inv=tkSimpleDialog.askstring('**Nombre de .csv:','')
>>  print 'Archivo de salida: ',inv
>>
>csv_name = inv
>
>
> def boton4():
>> #In this button I want to make a bigger process, but I need the root
>> selected and the two strings the user types.
>>  print csv.inv #Obviously this throws an error
>>
>
>print dir,csv_name,extn
>
> But course in a GUI you would normally not use print but instead populate
> the text field of a label or Text widget or some such
> device.
>
>
> --
> Alan G
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
>
> __**_
> Tutor maillist  -  Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/**mailman/listinfo/tutor
>
___
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor