Index
2009-08-08 12:49 – John : [dabo-users] will this work for a Mac?
2009-08-08 13:24 – Ed Leafe : Re: [dabo-users] will this work for a Mac?
2009-08-08 18:35 – John : Re: [dabo-users] will this work for a Mac?
2009-08-08 18:50 – Ed Leafe : Re: [dabo-users] will this work for a Mac?
2009-08-08 19:46 – John : Re: [dabo-users] will this work for a Mac?
2009-08-08 19:58 – Ed Leafe : Re: [dabo-users] will this work for a Mac?
2009-08-08 23:07 – Paul McNett : Re: [dabo-users] will this work for a Mac?
2009-08-08 23:16 – Ed Leafe : Re: [dabo-users] will this work for a Mac?
2009-08-09 02:52 – Paul McNett : Re: [dabo-users] will this work for a Mac?
2009-08-09 10:00 – John : Re: [dabo-users] will this work for a Mac?
Back to top
[dabo-users] will this work for a Mac?

Author: John

Posted: 2009-08-08 12:49:46   Link

I'm writing an article for the wiki and was wondering if the below code will

work on a Mac to find the file 'uno.py'.

import os

myflag = False

for direct in os.walk('/usr'):

for wds in direct[1]:

pathlist = '/usr/' + wds

for x in os.walk(pathlist):

for fn in x[2]:

if fn == 'uno.py':

path_to_file = x[0]+'/'+fn

myflag= True

print path_to_file

break

if myflag:

break

if myflag:

break

Johnf

©2009 John
Back to top
Re: [dabo-users] will this work for a Mac?

Author: Ed Leafe

Posted: 2009-08-08 13:24:56   Link

On Aug 8, 2009, at 11:49 AM, John wrote:

> I'm writing an article for the wiki and was wondering if the below

> code will

> work on a Mac to find the file 'uno.py'.

Possibly, but there are several things there that are problematic.

First, assuming that the user has access rights to /usr is never

smart. Second, Mac apps are typically self-contained; if uno.py is

needed for the app, it will be contained in the Resources subdirectory

inside the app itself, rather than installed in a system location.

Third, you should use os.sep instead of hard-coding '/' as the path

separator.

Lastly, does this actually work in Linux? Doesn't os.walk

automatically recurse? It seems that you have recursion inside of

recursion.

-- Ed Leafe

©2009 Ed Leafe
Back to top
Re: [dabo-users] will this work for a Mac?

Author: John

Posted: 2009-08-08 18:35:32   Link

On Saturday 08 August 2009 10:24:56 am Ed Leafe wrote:

> On Aug 8, 2009, at 11:49 AM, John wrote:

> > I'm writing an article for the wiki and was wondering if the below

> > code will

> > work on a Mac to find the file 'uno.py'.

>

> Possibly, but there are several things there that are problematic.

> First, assuming that the user has access rights to /usr is never

> smart. Second, Mac apps are typically self-contained; if uno.py is

> needed for the app, it will be contained in the Resources subdirectory

> inside the app itself, rather than installed in a system location.

> Third, you should use os.sep instead of hard-coding '/' as the path

> separator.

>

> Lastly, does this actually work in Linux? Doesn't os.walk

> automatically recurse? It seems that you have recursion inside of

> recursion.

>

>

> -- Ed Leafe

Doesn't a user have to have access to /usr/bin? If that is true then reading

anything under /usr is possible - right?

Works on Linux and windows (just change the starting location for windows).

But I'm always open to better code. os.sep is much better - thanks.

The problem with uno.py is it does not following standard python practice. On

linux (ubuntu and openSUSE) uno.py is in "/usr/lib/ooo3/basis3.1/program" and

there is no pth file created from the install of openoffice. Windows is

similar. So I was hoping I could find the file and add the path to

PythonPath.

I don't have a Mac but I was hoping to again to just find the file (assuming

the openoffice install did not register the file). And again add the

location to the path. But it sounds like that will not work?

I'm writing the article on how to use Dabo with openoffice. I'm also setting

up an openoffice server/client environment using two computers. It's geeky

cool to be able to create a doc (and print it) on a server anywhere on the

lan or wlan. Anyway I think it's cool.

Johnf

©2009 John
Back to top
Re: [dabo-users] will this work for a Mac?

Author: Ed Leafe

Posted: 2009-08-08 18:50:44   Link

On Aug 8, 2009, at 5:35 PM, John wrote:

> Doesn't a user have to have access to /usr/bin? If that is true

> then reading

> anything under /usr is possible - right?

It depends on the usr and the directory. The code could barf if it

hit a directory for which the user does not have read privs. I just

tried it on my machine:

[ed@Homer ~]$ find /usr -iname uno.py

find: /usr/local/pgsql/data: Permission denied

find: /usr/share/wikid/help/de.lproj/wiki: Permission denied

find: /usr/share/wikid/help/en.lproj/wiki: Permission denied

find: /usr/share/wikid/help/fr.lproj/wiki: Permission denied

find: /usr/share/wikid/help/ja.lproj/wiki: Permission denied

So it looks like it will hit some bumps. Oh, and there is no uno.py

there. But if I look in the application bundle:

[ed@Homer ~]$ find /Applications/NeoOffice.app -iname uno.py

/Applications/NeoOffice.app/Contents/MacOS/uno.py

> Works on Linux and windows (just change the starting location for

> windows).

> But I'm always open to better code. os.sep is much better - thanks.

>

> The problem with uno.py is it does not following standard python

> practice. On

> linux (ubuntu and openSUSE) uno.py is in "/usr/lib/ooo3/basis3.1/

> program" and

> there is no pth file created from the install of openoffice.

> Windows is

> similar. So I was hoping I could find the file and add the path to

> PythonPath.

>

> I don't have a Mac but I was hoping to again to just find the file

> (assuming

> the openoffice install did not register the file). And again add the

> location to the path. But it sounds like that will not work?

Doesn't look like it. Mac apps are distributed in "bundles": a

directory that appears in the OS as a single, double-clickable file,

but which contains all dependencies.

-- Ed Leafe

©2009 Ed Leafe
Back to top
Re: [dabo-users] will this work for a Mac?

Author: John

Posted: 2009-08-08 19:46:07   Link

On Saturday 08 August 2009 03:50:44 pm Ed Leafe wrote:

> On Aug 8, 2009, at 5:35 PM, John wrote:

> > Doesn't a user have to have access to /usr/bin? If that is true

> > then reading

> > anything under /usr is possible - right?

>

> It depends on the usr and the directory. The code could barf if it

> hit a directory for which the user does not have read privs. I just

> tried it on my machine:

>

> [ed@Homer ~]$ find /usr -iname uno.py

> find: /usr/local/pgsql/data: Permission denied

> find: /usr/share/wikid/help/de.lproj/wiki: Permission denied

> find: /usr/share/wikid/help/en.lproj/wiki: Permission denied

> find: /usr/share/wikid/help/fr.lproj/wiki: Permission denied

> find: /usr/share/wikid/help/ja.lproj/wiki: Permission denied

>

> So it looks like it will hit some bumps. Oh, and there is no uno.py

> there. But if I look in the application bundle:

>

> [ed@Homer ~]$ find /Applications/NeoOffice.app -iname uno.py

> /Applications/NeoOffice.app/Contents/MacOS/uno.py

>

> > Works on Linux and windows (just change the starting location for

> > windows).

> > But I'm always open to better code. os.sep is much better - thanks.

> >

> > The problem with uno.py is it does not following standard python

> > practice. On

> > linux (ubuntu and openSUSE) uno.py is in "/usr/lib/ooo3/basis3.1/

> > program" and

> > there is no pth file created from the install of openoffice.

> > Windows is

> > similar. So I was hoping I could find the file and add the path to

> > PythonPath.

> >

> > I don't have a Mac but I was hoping to again to just find the file

> > (assuming

> > the openoffice install did not register the file). And again add the

> > location to the path. But it sounds like that will not work?

>

> Doesn't look like it. Mac apps are distributed in "bundles": a

> directory that appears in the OS as a single, double-clickable file,

> but which contains all dependencies.

>

>

> -- Ed Leafe

So I'll tell the reader that they'll have to find the file and somehow get it

to import? Can you import the file from a Dabo app?

Johnf

©2009 John
Back to top
Re: [dabo-users] will this work for a Mac?

Author: Ed Leafe

Posted: 2009-08-08 19:58:58   Link

On Aug 8, 2009, at 6:46 PM, John wrote:

> So I'll tell the reader that they'll have to find the file and

> somehow get it

> to import? Can you import the file from a Dabo app?

Probably not, as it isn't in my path. I would imagine that anyone who

wants to use this will have to install it themselves.

-- Ed Leafe

©2009 Ed Leafe
Back to top
Re: [dabo-users] will this work for a Mac?

Author: Paul McNett

Posted: 2009-08-08 23:07:23   Link

Ed Leafe wrote:

> Doesn't look like it. Mac apps are distributed in "bundles": a

> directory that appears in the OS as a single, double-clickable file,

> but which contains all dependencies.

Not necessarily all dependencies. A bundle could use the system python

instead of bundling a specific python, for example.

Paul

©2009 Paul McNett
Back to top
Re: [dabo-users] will this work for a Mac?

Author: Ed Leafe

Posted: 2009-08-08 23:16:19   Link

On Aug 8, 2009, at 10:07 PM, Paul McNett wrote:

> Not necessarily all dependencies. A bundle could use the system python

> instead of bundling a specific python, for example.

True, but specific modules, such as uno.py, are usually bundled.

-- Ed Leafe

©2009 Ed Leafe
Back to top
Re: [dabo-users] will this work for a Mac?

Author: Paul McNett

Posted: 2009-08-09 02:52:19   Link

Ed Leafe wrote:

> On Aug 8, 2009, at 10:07 PM, Paul McNett wrote:

>

>> Not necessarily all dependencies. A bundle could use the system python

>> instead of bundling a specific python, for example.

>

>

> True, but specific modules, such as uno.py, are usually bundled.

Back onto the topic at hand, I think at least in years past OpenOffice

bundled a specific python that *had* to be used with the py-uno bridge.

Perhaps the system python can be used now but they still prefer you use

the Python that comes with OpenOffice, which would explain why they

don't install uno.py in the system python's site-packages.

Not sure what to recommend as far as packaging uno.py, as it depends on

OpenOffice and I sure wouldn't want to bundle OpenOffice in an app I

distribute.

So I see John's quandary.

Paul

©2009 Paul McNett
Back to top
Re: [dabo-users] will this work for a Mac?

Author: John

Posted: 2009-08-09 10:00:32   Link

On Saturday 08 August 2009 11:52:19 pm Paul McNett wrote:

> Ed Leafe wrote:

> > On Aug 8, 2009, at 10:07 PM, Paul McNett wrote:

> >> Not necessarily all dependencies. A bundle could use the system python

> >> instead of bundling a specific python, for example.

> >

> > True, but specific modules, such as uno.py, are usually bundled.

>

> Back onto the topic at hand, I think at least in years past OpenOffice

> bundled a specific python that *had* to be used with the py-uno bridge.

> Perhaps the system python can be used now but they still prefer you use

> the Python that comes with OpenOffice, which would explain why they

> don't install uno.py in the system python's site-packages.

>

> Not sure what to recommend as far as packaging uno.py, as it depends on

> OpenOffice and I sure wouldn't want to bundle OpenOffice in an app I

> distribute.

>

> So I see John's quandary.

>

> Paul

I'm not to sure about the history. But I have been able to use both 2.4 and

2.5 python on openoffice 3.

I created a pth file to point to the uno.py folder and it works for me. That

will be my suggestion to the reader instead of helping them find the file.

While I'm doing that I'll publish a screencast of Larry's front end to Paul's

report writer. I like it and it's another example of a real world app.

Thanks for the discussion.

Johnf

©2009 John