Re: script in Linux vs Windows

2010-10-09 Thread aurfalien

On Oct 8, 2010, at 9:33 PM, Dennis Lee Bieber wrote:


On Fri, 8 Oct 2010 14:52:33 -0700, aurfal...@gmail.com declaimed the
following in gmane.comp.python.general:


Hi all,

Unsure how to deal with what appears to be \n vs \r issues.

The following code works in Linux;

o = open("axenfs.reg")
n = open("axenfs2.reg", "a")


Why are you opening in "a"ppend? If you want to create a new file
containing the edited contents of the input file, just open "w".



But in Windows, its one continues line with a bunch of squares in it.


In Windows WHAT? Notepad, Wordpad, Word, a command console using
"type".


Geez man, relax.  I thought it was obvious by the code that I was  
opening it using Python.


I changed a to w and added a b, so all is well now, ie:  "wb"

Still don't know why Windows treats text files as binary files but  
using wb worked well.


- aurf
--
http://mail.python.org/mailman/listinfo/python-list


Re: script in Linux vs Windows

2010-10-08 Thread aurfalien


On Oct 8, 2010, at 4:27 PM, Ian Kelly wrote:


On Fri, Oct 8, 2010 at 3:52 PM,  wrote:
Hi all,

Unsure how to deal with what appears to be \n vs \r issues.

The following code works in Linux;

o = open("axenfs.reg")
n = open("axenfs2.reg", "a")
while 1:
 line = o.readline()
 if not line: break
 line = line.replace("dword:0","dword:044e")
 n.write(line)
n.close()

But in Windows, its one continues line with a bunch of squares in it.

So I add + '\r\n' to my second to last line so it looks like;

n.write(line + '\r\n')

But I still get one continuous line with squares in it.

Any ideas?  I've been googing all day to no avail.

Is the input file formatted the same way?  I would guess that the  
readline call is reading the input file as one continuous line, so  
that the loop body only runs once, and the '\r\n' only gets added to  
the very end of the file.


Hi Ian,

Thanks very much for the reply.

It took a very long time to get my approval mail for this list, so in  
the interum, I fix it this way (in the event other noobs have issues  
like myself).


First, I replaced "a" with "ab" as Winblows treats text files diff  
then Unix.


Second, I used variables instead of actual text so "dword:0" is  
really a var named oldhexuid.  And "dword:044e" is really a new  
var called newhexuid.


What I am really doing here is using NFS in 64 bit Windows XP via  
AxeNFS client which also works in Windows 7.


If you are asking why as Windows 7 does have NFS, it does not map UIDs  
like Windows XP 32 + SFU can do.  So basically I load an LDAP plugin  
for Windows called pGina which is an LDAP client for Windows.


Then during login, I NFS mount, scan a Linux passwd file on that NFS  
mount for the matching UID of the logged in Windows user and mod the  
reg so that the windows user UID matches the Linux UID.


This way  when they mod a file/ folder on the NFS mount, its got  
proper UID/GID values system wide.


Its really too bad the Windows 7 doesn't support NFS map files in  
terms of matching users with UID/GID.


And I didn't want to use Samba as I like my OpenLDAP servers clean and  
tidy.


Since the reg value is in hex, I had to convert the decimal value  
derived from the passwd file to hex via a sysinternals program called  
hex2dec.  Its this value that I use to mod the reg for AxeNFS.


This was a royal PITA but my constraints were clear and no flexible.

Hope this helps others.


- aurf

-- 
http://mail.python.org/mailman/listinfo/python-list


script in Linux vs Windows

2010-10-08 Thread aurfalien

Hi all,

Unsure how to deal with what appears to be \n vs \r issues.

The following code works in Linux;

o = open("axenfs.reg")
n = open("axenfs2.reg", "a")
while 1:
 line = o.readline()
 if not line: break
 line = line.replace("dword:0","dword:044e")
 n.write(line)
n.close()

But in Windows, its one continues line with a bunch of squares in it.

So I add + '\r\n' to my second to last line so it looks like;

n.write(line + '\r\n')

But I still get one continuous line with squares in it.

Any ideas?  I've been googing all day to no avail.

Desperately seeking advice.

- aurf
--
http://mail.python.org/mailman/listinfo/python-list


script in Linux vs Windows

2010-10-08 Thread aurfalien

Hi all,

Unsure how to deal with what appears to be \n vs \r issues.

The following code works in Linux;

o = open("axenfs.reg")
n = open("axenfs2.reg", "a")
while 1:
  line = o.readline()
  if not line: break
  line = line.replace("dword:0","dword:044e")
  n.write(line)
n.close()

But in Windows, its one continues line with a bunch of squares in it.

So I add + '\r\n' to my second to last line so it looks like;

n.write(line + '\r\n')

But I still get one continuous line with squares in it.

Any ideas?  I've been googing all day to no avail.

Desperately seeking advice.

- aurf
--
http://mail.python.org/mailman/listinfo/python-list


msg.attach multiple attachments and passing vars to html

2010-08-31 Thread aurfalien

Hi,

Few questions as I've been at this for dayz.

Can I do multiple attachments in order via msg.attach as so;

part1 = MIMEText(html, 'html')
msg.attach(part1)
part2 = MIMEText(text, 'plain')
msg.attach(part2)
part3 = MIMEText(html, 'html')
msg.attach(part3)

I desire to attach part1, part2 and part3 in that order.

Also, is it somehow possible to pas python vars to html?

My goal to to have an email that says something like;

Welcome to ACME.

A few LINKS to get you started.

Your user name is USRNM and your password is PASS

Where USRNM and PASS are python vars but the rest is an html based  
email.


LINKS is an actual hyperlink, hence the desire to do html based emails.

Thanks in advance,

- aurf
--
http://mail.python.org/mailman/listinfo/python-list


TypeError: unsupported operand types for +: 'NoneType' and 'str'

2009-11-17 Thread aurfalien

Hi all,

I tried to make the subject as specific as possible rather then just  
"help me" or "its broke" or "my server is down", etc...


So please excuse me if its too specific as I wasn't trying to be  
ridiculous.


So I've been handed some one else's work to fix.

While its fun and all, I haven't had much luck in debugging this  
particular issue.


The error I get;

File "myscript.py", Line 18, in ?
projectpath = ourHome+"/etc/TEMPLATE"
TypeError: unsupported operand type(s) for +: 'NoneType' and 'str'

Python 2.4.3

I've read were when passing a string to exec may need to end with a '\n'

I've tried a few diff variations on the below line 18 w/o luck.  Any  
one mind helping out a bratha from anatha ... planet that is?


line 18;

projectpath = ourHome+"/etc/TEMPLATE"

line 17;
ourHome = os.environ.get('some_env')


Thanks in advance,
- aurf




--
http://mail.python.org/mailman/listinfo/python-list