FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Gentoo > Gentoo Development

 
 
LinkBack Thread Tools
 
Old 05-30-2010, 02:59 PM
Christopher Harvey
 
Default showing file diffs as root

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello gentoo-dev,

I'm working on an app for GSoC that needs to show a diff of two files
to the user. Right now I've just been calling meld from the python
os.system call. I tried running my application as root to show diffs
of system files that belong to root. I got this error:

Traceback (most recent call last):
File "/usr/bin/meld", line 90, in <module>
meldapp.main()
File "/usr/lib/meld/meldapp.py", line 982, in main
app = MeldApp()
File "/usr/lib/meld/meldapp.py", line 562, in __init__
self.prefs = MeldPreferences()
File "/usr/lib/meld/meldapp.py", line 435, in __init__
super(MeldPreferences, self).__init__("/apps/meld", self.defaults)
File "/usr/lib/meld/prefs.py", line 92, in __init__
self._gconf.add_dir(rootkey, gconf.CLIENT_PRELOAD_NONE)
glib.GError: Failed to contact configuration server; some possible
causes are that you need to enable TCP/IP networking for ORBit, or you
have stale NFS locks due to a system crash. See
http://projects.gnome.org/gconf/ for information. (Details - 1:
Failed to get connection to session: Did not receive a reply. Possible
causes include: the remote application did not send a reply, the
message bus security policy blocked the reply, the reply timeout
expired, or the network connection was broken.)

I haven't looked into why this is happening very much because calling
os.system("meld file1 file2 &") in python is putting up so many red
flags in my head it's not funny. If anybody could tell me the proper
gentoo/linux/python way to present a root level diff to a user running
a program through su or sudo I'd really appreciate the help.

thanks,
Chris

- --
My GnuPGP key at:
www.basementcode.com/public_key.txt
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJMAn1RAAoJEDqfZIFeqFH7brQH/RqeUmCHuopa+SufkzNNT4Ys
7IJArQCik3vBLJLpeTM3gf3NL3KMWjyzlxxQ8L74KAhItPuA3c VUQKQrSnOCBiDa
y6yfDttBbOptOtcUYn7WkXQDm+BYEdpviMfjtym5ZF2nlGOMzZ MxknP4ywXnhLZN
q2169haoG0p1g0D11q2H9B4Vk++PUil7VLgzOfAOcLQ9YpFDkX Idxy5FRaRkx8K4
lcPfmzFha8OkdBpsXPJdhtY5pmzOEf+ziprDlyD7eCkE1xAkRN hjsNtEz9CTXeLh
l46/tUCZTx+aX9ABW0m13Ache8jGN36+TvsRzRKfzqaMJ0z/wEOeESooPFYHnl0=
=FxxJ
-----END PGP SIGNATURE-----
 
Old 05-30-2010, 03:21 PM
Domen Kožar
 
Default showing file diffs as root

Hey!

Maybe I am missing something, but why not use difflib and pygments on
top of that?

Cheers, Domen

On Sun, 2010-05-30 at 10:59 -0400, Christopher Harvey wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hello gentoo-dev,
>
> I'm working on an app for GSoC that needs to show a diff of two files
> to the user. Right now I've just been calling meld from the python
> os.system call. I tried running my application as root to show diffs
> of system files that belong to root. I got this error:
>
> Traceback (most recent call last):
> File "/usr/bin/meld", line 90, in <module>
> meldapp.main()
> File "/usr/lib/meld/meldapp.py", line 982, in main
> app = MeldApp()
> File "/usr/lib/meld/meldapp.py", line 562, in __init__
> self.prefs = MeldPreferences()
> File "/usr/lib/meld/meldapp.py", line 435, in __init__
> super(MeldPreferences, self).__init__("/apps/meld", self.defaults)
> File "/usr/lib/meld/prefs.py", line 92, in __init__
> self._gconf.add_dir(rootkey, gconf.CLIENT_PRELOAD_NONE)
> glib.GError: Failed to contact configuration server; some possible
> causes are that you need to enable TCP/IP networking for ORBit, or you
> have stale NFS locks due to a system crash. See
> http://projects.gnome.org/gconf/ for information. (Details - 1:
> Failed to get connection to session: Did not receive a reply. Possible
> causes include: the remote application did not send a reply, the
> message bus security policy blocked the reply, the reply timeout
> expired, or the network connection was broken.)
>
> I haven't looked into why this is happening very much because calling
> os.system("meld file1 file2 &") in python is putting up so many red
> flags in my head it's not funny. If anybody could tell me the proper
> gentoo/linux/python way to present a root level diff to a user running
> a program through su or sudo I'd really appreciate the help.
>
> thanks,
> Chris
>
> - --
> My GnuPGP key at:
> www.basementcode.com/public_key.txt
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v2.0.14 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iQEcBAEBAgAGBQJMAn1RAAoJEDqfZIFeqFH7brQH/RqeUmCHuopa+SufkzNNT4Ys
> 7IJArQCik3vBLJLpeTM3gf3NL3KMWjyzlxxQ8L74KAhItPuA3c VUQKQrSnOCBiDa
> y6yfDttBbOptOtcUYn7WkXQDm+BYEdpviMfjtym5ZF2nlGOMzZ MxknP4ywXnhLZN
> q2169haoG0p1g0D11q2H9B4Vk++PUil7VLgzOfAOcLQ9YpFDkX Idxy5FRaRkx8K4
> lcPfmzFha8OkdBpsXPJdhtY5pmzOEf+ziprDlyD7eCkE1xAkRN hjsNtEz9CTXeLh
> l46/tUCZTx+aX9ABW0m13Ache8jGN36+TvsRzRKfzqaMJ0z/wEOeESooPFYHnl0=
> =FxxJ
> -----END PGP SIGNATURE-----
>
>
 
Old 05-30-2010, 03:27 PM
Christopher Harvey
 
Default showing file diffs as root

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 05/30/10 11:21, Domen Kožar wrote:
> Hey!
>
> Maybe I am missing something, but why not use difflib and pygments on
> top of that?
>
> Cheers, Domen
>

That's a good option.
Pros:
Can easily integrate the diff viewer into my application.

Cons:
Doesn't seem to be a way to interactively merge files (not a big deal
for me)

As for generating the diff is it ok to use difflib to generate the diff
text? I hear there is a diff environment variable..(but I can't seem to
find it now) should I use that instead?

- --
My GnuPGP key at:
www.basementcode.com/public_key.txt
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJMAoPtAAoJEDqfZIFeqFH7+NYH/3J6IS4woiS5KI3KIDdPA5eU
9VBaC8xRJEJ/fwYXoxaRqkWft2hAd/FahbPMzZI9RiA3tEu8Cv8NE6nvtXTJoe6U
zJ/8gIszJVEG3QnADvzdSr03kCWCsom5iZBuEYP0eK/VT9cgsjiTsc71p0h7zcIK
TosCrKMkya3IJ3svBXLnJhgtcekfmP2Qk8gQt4o/UMW1D7abP5kI2zxidgsGEL1V
YBu4HOirte9RFzEIZBClFW0LpUZ0Ix2Rpf614GvAEW+5HK34hf QHMxdmPCVVLv7W
KNMspLUOaOEVnufhz8i5UvKvbMCjj5PItTvEQlsJ/xzrB2bZqIWK1iYZp07PdmI=
=CWy/
-----END PGP SIGNATURE-----
 
Old 05-30-2010, 03:34 PM
Domen Kožar
 
Default showing file diffs as root

difflib is one of the best Python libraries out there. It does it's job
perfectly.

difflib can generate diff in text, any it's very pluggable (go through
documentation, you will see)

On Sun, 2010-05-30 at 11:27 -0400, Christopher Harvey wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On 05/30/10 11:21, Domen Kožar wrote:
> > Hey!
> >
> > Maybe I am missing something, but why not use difflib and pygments on
> > top of that?
> >
> > Cheers, Domen
> >
>
> That's a good option.
> Pros:
> Can easily integrate the diff viewer into my application.
>
> Cons:
> Doesn't seem to be a way to interactively merge files (not a big deal
> for me)
>
> As for generating the diff is it ok to use difflib to generate the diff
> text? I hear there is a diff environment variable..(but I can't seem to
> find it now) should I use that instead?
>
> - --
> My GnuPGP key at:
> www.basementcode.com/public_key.txt
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v2.0.14 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iQEcBAEBAgAGBQJMAoPtAAoJEDqfZIFeqFH7+NYH/3J6IS4woiS5KI3KIDdPA5eU
> 9VBaC8xRJEJ/fwYXoxaRqkWft2hAd/FahbPMzZI9RiA3tEu8Cv8NE6nvtXTJoe6U
> zJ/8gIszJVEG3QnADvzdSr03kCWCsom5iZBuEYP0eK/VT9cgsjiTsc71p0h7zcIK
> TosCrKMkya3IJ3svBXLnJhgtcekfmP2Qk8gQt4o/UMW1D7abP5kI2zxidgsGEL1V
> YBu4HOirte9RFzEIZBClFW0LpUZ0Ix2Rpf614GvAEW+5HK34hf QHMxdmPCVVLv7W
> KNMspLUOaOEVnufhz8i5UvKvbMCjj5PItTvEQlsJ/xzrB2bZqIWK1iYZp07PdmI=
> =CWy/
> -----END PGP SIGNATURE-----
>
 
Old 05-30-2010, 04:08 PM
Michał Górny
 
Default showing file diffs as root

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Sun, 30 May 2010 11:27:41 -0400
Christopher Harvey <chris@basementcode.com> wrote:

> As for generating the diff is it ok to use difflib to generate the
> diff text? I hear there is a diff environment variable..(but I can't
> seem to find it now) should I use that instead?

If I correctly understand what you're referring to, that variable is
useful if you just need to present the diff to the user in the format
preferred by him -- he could then choose an alternate diffing program,
offering another output format.

If you need to parse the differences, that's not an option for you as
the diffing program chosen by user might use any freeform output
format, making it unparseable. Thus, in that case difflib is the solu-
tion you're looking for -- it is prepared to provide the differences
in a way suitable for program use.


- --
Best regards,
Michał Górny

<http://mgorny.alt.pl>
<xmpp:mgorny@jabber.ru>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.15 (GNU/Linux)

iEYEARECAAYFAkwCjW0ACgkQnGSe5QXeB7uojwCg5bXcUVGR48 7tyuU+wnNDG5fA
JMkAoKiqCHJXsmQz7aYGU+J+BzTPwQsn
=lRtw
-----END PGP SIGNATURE-----
 
Old 05-30-2010, 08:34 PM
Sebastian Pipping
 
Default showing file diffs as root

On 05/30/10 16:59, Christopher Harvey wrote:
> [..] because calling
> os.system("meld file1 file2 &") in python is putting up so many red
> flags in my head it's not funny. [..]

On a sidenote: the subprocess module offers better alternatives to
calling os.system:
http://docs.python.org/library/subprocess.html

Best,



Sebastian
 
Old 05-31-2010, 12:21 PM
Francesco R
 
Default showing file diffs as root

why not make a temporary copy of the files with appropriate permission,*send a message the application the user originally opened to diff the files,then apply the user modified file and cleanup the $tmpdir?

This would leave the user the possibility to choose whatever application she want to do the merge, which is a big plus.
2010/5/30 Christopher Harvey <chris@basementcode.com>

-----BEGIN PGP SIGNED MESSAGE-----

Hash: SHA1



Hello gentoo-dev,



I'm working on an app for GSoC that needs to show a diff of two files

to the user. Right now I've just been calling meld from the python

os.system call. I tried running my application as root to show diffs

of system files that belong to root. I got this error:



Traceback (most recent call last):

*File "/usr/bin/meld", line 90, in <module>

* *meldapp.main()

*File "/usr/lib/meld/meldapp.py", line 982, in main

* *app = MeldApp()

*File "/usr/lib/meld/meldapp.py", line 562, in __init__

* *self.prefs = MeldPreferences()

*File "/usr/lib/meld/meldapp.py", line 435, in __init__

* *super(MeldPreferences, self).__init__("/apps/meld", self.defaults)

*File "/usr/lib/meld/prefs.py", line 92, in __init__

* *self._gconf.add_dir(rootkey, gconf.CLIENT_PRELOAD_NONE)

glib.GError: Failed to contact configuration server; some possible

causes are that you need to enable TCP/IP networking for ORBit, or you

have stale NFS locks due to a system crash. See

http://projects.gnome.org/gconf/ for information. (Details - *1:

Failed to get connection to session: Did not receive a reply. Possible

causes include: the remote application did not send a reply, the

message bus security policy blocked the reply, the reply timeout

expired, or the network connection was broken.)



I haven't looked into why this is happening very much because calling

os.system("meld file1 file2 &") in python is putting up so many red

flags in my head it's not funny. If anybody could tell me the proper

gentoo/linux/python way to present a root level diff to a user running

a program through su or sudo I'd really appreciate the help.



thanks,

Chris



- --

My GnuPGP key at:

www.basementcode.com/public_key.txt

-----BEGIN PGP SIGNATURE-----

Version: GnuPG v2.0.14 (GNU/Linux)

Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/



iQEcBAEBAgAGBQJMAn1RAAoJEDqfZIFeqFH7brQH/RqeUmCHuopa+SufkzNNT4Ys

7IJArQCik3vBLJLpeTM3gf3NL3KMWjyzlxxQ8L74KAhItPuA3c VUQKQrSnOCBiDa

y6yfDttBbOptOtcUYn7WkXQDm+BYEdpviMfjtym5ZF2nlGOMzZ MxknP4ywXnhLZN

q2169haoG0p1g0D11q2H9B4Vk++PUil7VLgzOfAOcLQ9YpFDkX Idxy5FRaRkx8K4

lcPfmzFha8OkdBpsXPJdhtY5pmzOEf+ziprDlyD7eCkE1xAkRN hjsNtEz9CTXeLh

l46/tUCZTx+aX9ABW0m13Ache8jGN36+TvsRzRKfzqaMJ0z/wEOeESooPFYHnl0=

=FxxJ

-----END PGP SIGNATURE-----
 
Old 05-31-2010, 12:57 PM
Gilles Dartiguelongue
 
Default showing file diffs as root

Le dimanche 30 mai 2010 10:59 -0400, Christopher Harvey a crit :
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hello gentoo-dev,
>
> I'm working on an app for GSoC that needs to show a diff of two files
> to the user. Right now I've just been calling meld from the python
> os.system call. I tried running my application as root to show diffs
> of system files that belong to root. I got this error:
>
> Traceback (most recent call last):
> File "/usr/bin/meld", line 90, in <module>
> meldapp.main()
> File "/usr/lib/meld/meldapp.py", line 982, in main
> app = MeldApp()
> File "/usr/lib/meld/meldapp.py", line 562, in __init__
> self.prefs = MeldPreferences()
> File "/usr/lib/meld/meldapp.py", line 435, in __init__
> super(MeldPreferences, self).__init__("/apps/meld", self.defaults)
> File "/usr/lib/meld/prefs.py", line 92, in __init__
> self._gconf.add_dir(rootkey, gconf.CLIENT_PRELOAD_NONE)
> glib.GError: Failed to contact configuration server; some possible
> causes are that you need to enable TCP/IP networking for ORBit, or you
> have stale NFS locks due to a system crash. See
> http://projects.gnome.org/gconf/ for information. (Details - 1:
> Failed to get connection to session: Did not receive a reply. Possible
> causes include: the remote application did not send a reply, the
> message bus security policy blocked the reply, the reply timeout
> expired, or the network connection was broken.)
>
> I haven't looked into why this is happening very much

https://bugs.gentoo.org/show_bug.cgi?id=286577
https://bugs.gentoo.org/show_bug.cgi?id=302597

and probably a couple more duplicates.

--
Gilles Dartiguelongue <eva@gentoo.org>
Gentoo
 

Thread Tools




All times are GMT. The time now is 12:03 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org