Re: Converting Excel time-format (hours since 1.1.1901)

2007-12-10 Thread Dirk Hagemann
On 9 Dez., 18:38, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote:
 On Dec 9, 8:52�am, Dirk Hagemann [EMAIL PROTECTED] wrote:



  On 7 Dez., 22:36, John Machin [EMAIL PROTECTED] wrote:

   On Dec 8, 12:20 am, Dirk Hagemann [EMAIL PROTECTED] wrote:

Hello,

From a zone-file of a Microsoft Active Directory integrated DNS server
I get the date/time of the dynamic update entries in a format, which
is as far as I know the hours since january 1st 1901.

   As Tim Golden has guessed, it is the number of hours since
   1601-01-01T00:00:00. Weird but true. See (for 
   example)http://www.netpro.com/forum/messageview.cfm?catid=15threadid=457

For Example: the number 3566839 is 27.11.07 7:00.

   Y2K bug! The number 3566839 is a representation of
   2007-11-27T07:00:00.

To calculate this in
   ExcelI use this:
=01.01.1901+(A1/24-(REST(A1;24)/24))+ZEIT(REST(A1;24);0;0) �(put
3566839 in field A1 and switch the format of the result-field to the
corresponding date-time format).

   01.01.1901 = date(1901, 1, 1)

   (A1/24-(REST(A1;24)/24)) = (A1/24-(MOD(A1,24)/24))
   which simplifies to INT(A1/24)

   ZEIT(REST(A1;24);0;0) = TIME(MOD(A1,24),0,0)

   This is a convoluted way of writing DATE(1901, 1, 1) + A1 / 24

   Your result is correct apart from the century. This is the result of
   two canceling errors (1) yours in being 3 centuries out of kilter (2)
   Microsoft's in perpetuating the Lotus 123 1900 is a leap year bug.

   If you must calculate this inExcel, this formula might be better:

   =DATE(2001, 1, �1) + A1 / 24 - 146097

   (146097 is the number of days in a 400-year cycle, 400 * 365 + 100 - 4
   + 1)

You might guess what I need now: I want to calculate this somehow in
python.

Sorry, but I couldn't find anything in the module time or something
else to get this calculated.

Does anyone know how to convert this time in python to something
usable or how to convert this formula in python?

   One very slight change to what Tim Golden suggested: make the result a
   datetime, not a date.

dnsdatetime2py = lambda x: datetime.datetime(1601,1,1,0,0,0) + 
datetime.timedelta(hours=x)
dnsdatetime2py(3566839) # your example

   datetime.datetime(2007, 11, 27, 7, 0) dnsdatetime2py(3554631) # 
   example in cited web posting

   datetime.datetime(2006, 7, 6, 15, 0)

   HTH,
   John

  YES - that's it!
  Thanks a lot to John, Tim and all the others who helped me to handle
  this time format!!!

  I was irritated by the date of 01.01.1901 in the Excel formula, but in
  the end it was obvious that it has to be hours since 1601. Who knows
  how Excel calculates in the background...

 Everyone knows. Excel assumes an integer is
 DAYS SINCE 1900 and all it's calculations
 are based on that assumption.

 It's YOUR fault if you give Excel an integer
 that represents HOURS SINCE 1601, so don't
 expect meaningful calculations from Excel if
 you give it an incorrect data type.



  Enjoy the sunday and have a great week!
  Dirk

Sorry, but then I seem not to belong to everyone. And it was not me
who created this Excel-formula, I just posted it as a kind of help.
And actually I just asked if somebody knows something about this time-
format and how to convert it. I think I already wrote that I did a
mistake and not Excel.
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Converting Excel time-format (hours since 1.1.1901)

2007-12-09 Thread Dirk Hagemann
On 7 Dez., 22:36, John Machin [EMAIL PROTECTED] wrote:
 On Dec 8, 12:20 am, Dirk Hagemann [EMAIL PROTECTED] wrote:

  Hello,

  From a zone-file of a Microsoft Active Directory integrated DNS server
  I get the date/time of the dynamic update entries in a format, which
  is as far as I know the hours since january 1st 1901.

 As Tim Golden has guessed, it is the number of hours since
 1601-01-01T00:00:00. Weird but true. See (for 
 example)http://www.netpro.com/forum/messageview.cfm?catid=15threadid=457

  For Example: the number 3566839 is 27.11.07 7:00.

 Y2K bug! The number 3566839 is a representation of
 2007-11-27T07:00:00.

  To calculate this in
 ExcelI use this:
  =01.01.1901+(A1/24-(REST(A1;24)/24))+ZEIT(REST(A1;24);0;0)  (put
  3566839 in field A1 and switch the format of the result-field to the
  corresponding date-time format).

 01.01.1901 = date(1901, 1, 1)

 (A1/24-(REST(A1;24)/24)) = (A1/24-(MOD(A1,24)/24))
 which simplifies to INT(A1/24)

 ZEIT(REST(A1;24);0;0) = TIME(MOD(A1,24),0,0)

 This is a convoluted way of writing DATE(1901, 1, 1) + A1 / 24

 Your result is correct apart from the century. This is the result of
 two canceling errors (1) yours in being 3 centuries out of kilter (2)
 Microsoft's in perpetuating the Lotus 123 1900 is a leap year bug.

 If you must calculate this inExcel, this formula might be better:

 =DATE(2001, 1,  1) + A1 / 24 - 146097

 (146097 is the number of days in a 400-year cycle, 400 * 365 + 100 - 4
 + 1)



  You might guess what I need now: I want to calculate this somehow in
  python.

  Sorry, but I couldn't find anything in the module time or something
  else to get this calculated.

  Does anyone know how to convert this time in python to something
  usable or how to convert this formula in python?

 One very slight change to what Tim Golden suggested: make the result a
 datetime, not a date.

  dnsdatetime2py = lambda x: datetime.datetime(1601,1,1,0,0,0) + 
  datetime.timedelta(hours=x)
  dnsdatetime2py(3566839) # your example

 datetime.datetime(2007, 11, 27, 7, 0) dnsdatetime2py(3554631) # example in 
 cited web posting

 datetime.datetime(2006, 7, 6, 15, 0)

 HTH,
 John

YES - that's it!
Thanks a lot to John, Tim and all the others who helped me to handle
this time format!!!

I was irritated by the date of 01.01.1901 in the Excel formula, but in
the end it was obvious that it has to be hours since 1601. Who knows
how Excel calculates in the background...

Enjoy the sunday and have a great week!
Dirk
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Converting Excel time-format (hours since 1.1.1901)

2007-12-07 Thread Dirk Hagemann
On 7 Dez., 14:34, supercooper [EMAIL PROTECTED] wrote:
 On Dec 7, 7:20 am, Dirk Hagemann [EMAIL PROTECTED] wrote:



  Hello,

  From a zone-file of a Microsoft Active Directory integrated DNS server
  I get the date/time of the dynamic update entries in a format, which
  is as far as I know the hours since january 1st 1901.
  For Example: the number 3566839 is 27.11.07 7:00. To calculate this in
  Excel I use this:
  =01.01.1901+(A1/24-(REST(A1;24)/24))+ZEIT(REST(A1;24);0;0)  (put
  3566839 in field A1 and switch the format of the result-field to the
  corresponding date-time format).

  You might guess what I need now: I want to calculate this somehow in
  python.

  Sorry, but I couldn't find anything in the module time or something
  else to get this calculated.

  Does anyone know how to convert this time in python to something
  usable or how to convert this formula in python?

  Thanks a lot and regards
  Dirk

 I think you want the xldate_as_tuple function in the xlrd module:

 http://www.lexicon.net/sjmachin/xlrd.htm

 It works like a champ for me:

  import xlrd
  xlrd.xldate.xldate_as_tuple(38980,0)

 (2006, 9, 20, 0, 0, 0)



 chad!

Thanks so far, that comes close to a solution I think, BUT when I
enter 3566985 instead of 38980 I get the following error:
Traceback (most recent call last):
  File test.py, line 20, in module
print xlrd.xldate.xldate_as_tuple(3566985,0)
  File C:\Python25\lib\site-packages\xlrd\xldate.py, line 75, in
xldate_as_tuple
raise XLDateTooLarge(xldate)
xlrd.xldate.XLDateTooLarge: 3566985

Do I have to use another function of this module? My number is 2
digits shorter than yours. What is 38980 representing?

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


Re: Converting Excel time-format (hours since 1.1.1901)

2007-12-07 Thread Dirk Hagemann
On 7 Dez., 16:50, Dirk Hagemann [EMAIL PROTECTED] wrote:
 On 7 Dez., 16:21, Tim Golden [EMAIL PROTECTED] wrote:



  [EMAIL PROTECTED] wrote:
   On Dec 7, 7:20�am, Dirk Hagemann [EMAIL PROTECTED] wrote:
   Hello,

   From a zone-file of a Microsoft Active Directory integrated DNS server
   I get the date/time of the dynamic update entries in a format, which
   is as far as I know the hours since january 1st 1901.

  If it *is* then the easiest way is this:

  code
  import datetime
  print datetime.date (1901, 1, 1) + datetime.timedelta (hours=3566839)

  /code

  But, as someone pointed out, that puts you somewhere in 2300.
  Where are you getting the 1901 from (and the hours, for that
  matter). If it's based, as AD dates are, for example, from 1601,
  then the calc becomes:

  code
  import datetime
  print datetime.date (1601, 1, 1) + datetime.timedelta (hours=3566839)

  /code

  which looks more realistic. But frankly I'm guessing.

  TJG

 (3566839/24)/365 = 407   - YES I did this calculation too and was
 surprised. But if you try this out in MS Excel:
  =01.01.1901+(A1/24-(REST(A1;24)/24))+ZEIT(REST(A1;24);0;0)  (put
 3566839 in field A1 and switch the format of the result-fieldby right-
 click on it to the
 date format 14.3.01 13:30)

 and then replace 3566839 by, let's say, 2, Excel calculates the date
 01.10.1901 2:00 AM. Try out other values like 5 or 24! So I thought
 3566839 represents hours.

 Dirk

Additional to my last posting: if you want to try this out in Excel
you should replace the command REST by the english command what
should be something like remainder.
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Converting Excel time-format (hours since 1.1.1901)

2007-12-07 Thread Dirk Hagemann
On 7 Dez., 16:21, Tim Golden [EMAIL PROTECTED] wrote:
 [EMAIL PROTECTED] wrote:
  On Dec 7, 7:20�am, Dirk Hagemann [EMAIL PROTECTED] wrote:
  Hello,

  From a zone-file of a Microsoft Active Directory integrated DNS server
  I get the date/time of the dynamic update entries in a format, which
  is as far as I know the hours since january 1st 1901.

 If it *is* then the easiest way is this:

 code
 import datetime
 print datetime.date (1901, 1, 1) + datetime.timedelta (hours=3566839)

 /code

 But, as someone pointed out, that puts you somewhere in 2300.
 Where are you getting the 1901 from (and the hours, for that
 matter). If it's based, as AD dates are, for example, from 1601,
 then the calc becomes:

 code
 import datetime
 print datetime.date (1601, 1, 1) + datetime.timedelta (hours=3566839)

 /code

 which looks more realistic. But frankly I'm guessing.

 TJG

(3566839/24)/365 = 407   - YES I did this calculation too and was
surprised. But if you try this out in MS Excel:
 =01.01.1901+(A1/24-(REST(A1;24)/24))+ZEIT(REST(A1;24);0;0)  (put
3566839 in field A1 and switch the format of the result-fieldby right-
click on it to the
date format 14.3.01 13:30)

and then replace 3566839 by, let's say, 2, Excel calculates the date
01.10.1901 2:00 AM. Try out other values like 5 or 24! So I thought
3566839 represents hours.

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

Converting Excel time-format (hours since 1.1.1901)

2007-12-07 Thread Dirk Hagemann
Hello,

From a zone-file of a Microsoft Active Directory integrated DNS server
I get the date/time of the dynamic update entries in a format, which
is as far as I know the hours since january 1st 1901.
For Example: the number 3566839 is 27.11.07 7:00. To calculate this in
Excel I use this:
=01.01.1901+(A1/24-(REST(A1;24)/24))+ZEIT(REST(A1;24);0;0)  (put
3566839 in field A1 and switch the format of the result-field to the
corresponding date-time format).

You might guess what I need now: I want to calculate this somehow in
python.

Sorry, but I couldn't find anything in the module time or something
else to get this calculated.

Does anyone know how to convert this time in python to something
usable or how to convert this formula in python?

Thanks a lot and regards
Dirk
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Converting Excel time-format (hours since 1.1.1901)

2007-12-07 Thread Dirk Hagemann
On 7 Dez., 16:50, Dirk Hagemann [EMAIL PROTECTED] wrote:
 On 7 Dez., 16:21, Tim Golden [EMAIL PROTECTED] wrote:



  [EMAIL PROTECTED] wrote:
   On Dec 7, 7:20�am, Dirk Hagemann [EMAIL PROTECTED] wrote:
   Hello,

   From a zone-file of a Microsoft Active Directory integrated DNS server
   I get the date/time of the dynamic update entries in a format, which
   is as far as I know the hours since january 1st 1901.

  If it *is* then the easiest way is this:

  code
  import datetime
  print datetime.date (1901, 1, 1) + datetime.timedelta (hours=3566839)

  /code

  But, as someone pointed out, that puts you somewhere in 2300.
  Where are you getting the 1901 from (and the hours, for that
  matter). If it's based, as AD dates are, for example, from 1601,
  then the calc becomes:

  code
  import datetime
  print datetime.date (1601, 1, 1) + datetime.timedelta (hours=3566839)

  /code

  which looks more realistic. But frankly I'm guessing.

  TJG

 (3566839/24)/365 = 407   - YES I did this calculation too and was
 surprised. But if you try this out in MS Excel:
  =01.01.1901+(A1/24-(REST(A1;24)/24))+ZEIT(REST(A1;24);0;0)  (put
 3566839 in field A1 and switch the format of the result-fieldby right-
 click on it to the
 date format 14.3.01 13:30)

 and then replace 3566839 by, let's say, 2, Excel calculates the date
 01.10.1901 2:00 AM. Try out other values like 5 or 24! So I thought
 3566839 represents hours.

 Dirk

Oh - sorry again: in the Excel formula replace also ZEIT with TIME.
-- 
http://mail.python.org/mailman/listinfo/python-list

Re: Active Directory: how to delete a user from a group?

2007-05-04 Thread Dirk Hagemann
On 2 Mai, 17:48, Tim Golden [EMAIL PROTECTED] wrote:
 Tim Golden wrote:
 Dirk Hagemannwrote:
  Hi!

  Does anyone has experience with manipulating MS Active Directory
  objects? I'd like to delete some users from a group, but so far I
  couldn't find anything about this.
  There is some good stuff about retrieving data out of the AD (thanks
  to Tim Golden!), but how can I manipulate or change AD objects like
  users, computers and groups with Python? Is there somewhere a
  documentation or some code?

  I freely admit I don't do too much changing of AD objects,
  but my module should at least support the methods for doing
  things. Some examples in Active Directory Cookbook:

 http://techtasks.com/code/viewbook/2

 Sorry, you wanted to remove a user *from a group*. Misread.

 Translated fromhttp://techtasks.com/code/viewbookcode/1626

 code
 import active_directory
 group = active_directory.find_group (name-of-group)
 # or group = active_directory.AD_object (group-moniker)

 user = active_directory.find_user (name-of-user)
 # or user = active_directory.AD_object (user-moniker)

 group.Remove (user.path ())

 /code

 Obviously, for something this simple using an extra module
 is overkill. You might as well:

 code
 import win32com.client

 group = win32com.client.GetObject (group-moniker)
 group.Remove (user-moniker)

 /code

 NB I haven't tried these, I've just translated them
 from the Cookbook site!

 TJG

Hi Tim!

The first code does exactly what I want - thanks a lot again for your
help.

Dirk

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


Active Directory: how to delete a user from a group?

2007-05-02 Thread Dirk Hagemann
Hi!

Does anyone has experience with manipulating MS Active Directory
objects? I'd like to delete some users from a group, but so far I
couldn't find anything about this.
There is some good stuff about retrieving data out of the AD (thanks
to Tim Golden!), but how can I manipulate or change AD objects like
users, computers and groups with Python? Is there somewhere a
documentation or some code?

Dirk

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


Re: MS SQL Server: NT Authentication. Possible?

2006-08-24 Thread Dirk Hagemann
 http://msdn.microsoft.com/msdnmag/issues/05/09/SecurityBriefs/
 http://msdn2.microsoft.com/en-us/library/bsz5788z.aspx

Thanks for the links Tim! This really seems to go in the right
direction. Tomorrow I will talk to my colleague who takes care of the
webserver.

Dirk

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


Re: MS SQL Server: NT Authentication. Possible?

2006-08-23 Thread Dirk Hagemann
I already mentioned, that it the following works when it's NOT executed
by the webserver:
 code
 import adodbapi

 db = adodbapi.connect (Provider=sqloledb;Data Source=VODEV1;Initial
 Catalog=EVOBACK;Integrated Security=SSPI;)
 q = db.cursor ()
 q.execute (SELECT SYSTEM_USER)
 print q.fetchone ()
 q.close ()
 /code

Now I found this work-around: I have on a fileserver some directories
with restricted rights. In every directory is a file which has always
the same name. Now I let the script (executed by the IIS-Webserver) try
to open this file (directory is chosen by the user):
data =
open(server\\directory\\+variable+\\index.py,r).readlines()
If the NT-Account of the user has the right to open this file, the
script will proceed with the addicted Database-View. If the user has
not the right he gets an error-message.

And this works! In this case the webserver is working on the fileserver
with the NT-account of the user who has used the webinterface. So on
the one hand the IIS works fine with the fileserver, but the IIS does
not work with the SQL-Server. And it seems not to be the fault of the
code, because it works when it's executed directly.
It's so confusing...

Dirk

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


Re: MS SQL Server: NT Authentication. Possible?

2006-08-22 Thread Dirk Hagemann
   You have a user named null?

   Off-hand, it looks very much like the CGI script is still running
 with the privileges of the web-server, and /that/ is set up in a locked
 down account that doesn't have connection rights.

I also thought this might be the reason, but when I include
username = os.environ.get('REMOTE_USER')
in this script and print the username, it's my NT-username and not a
webserver user.
By the way - the webserver is an IIS.
I once before had the problem that some code worked fine when I
directly executed it, but didn't work when executed by this webserver
(both again with the same user-account).
May be it has something to do with the IIS. I will try to find a
solution by reading these sites:
http://www.google.de/search?hl=deq=%22Login+failed+for+user+'(null)'%22+%22Not+associated+with+a+trusted+SQL+Server+connection%22btnG=Suchemeta=

Dirk

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


Re: MS SQL Server: NT Authentication. Possible?

2006-08-21 Thread Dirk Hagemann
 code
 import adodbapi

 db = adodbapi.connect (Provider=sqloledb;Data Source=VODEV1;Initial
 Catalog=EVOBACK;Integrated Security=SSPI;)
 q = db.cursor ()
 q.execute (SELECT SYSTEM_USER)
 print q.fetchone ()
 q.close ()

 /code


Cool! That works :-)
Thanks a lot (again) Tim!

Have a great week
Dirk

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


Re: MS SQL Server: NT Authentication. Possible?

2006-08-21 Thread Dirk Hagemann
Very strange. It works when I directly run the script, but when I use
this script as a CGI-script on a webserver, I get this error:
File D:\Web\test\adodbapi.py, line 224, in connect raise
DatabaseError(e) adodbapi.DatabaseError: (-2147352567, 'Exception
occurred.', (0, 'Microsoft OLE DB Provider for SQL Server', Login
failed for user '(null)'. Reason: Not associated with a trusted SQL
Server connection., None, 0, -2147467259), None)
The script on the webserver is started with the user who is logged on
to the client-computer (not a webserver-user). I checked this with
username = os.environ.get('REMOTE_USER') in the script.
What's wrong when a webserver runs this script?!

Dirk

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


MS SQL Server: NT Authentication. Possible?

2006-08-18 Thread Dirk Hagemann
Hi!
Is it somehow possible to access an MS SQL Server database from python
by NT-Authentication or do I have only the possibility to use an
SQL-Account with DB = odbc.odbc(myDB/myAccount/myPW) ?

Kind regards
Dirk

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


Re: MS SQL Server: NT Authentication. Possible?

2006-08-18 Thread Dirk Hagemann
Hi Tim!

I think the adodbapi module is interesting. I just tried it out but got
this error:
'Exception occurred.', (0, 'Microsoft OLE DB Provider for ODBC
Drivers', [Microsoft][ODBC SQL Server Driver][SQL Server]Login failed
for user '(null)'. Reason: Not associated with a trusted SQL Server
connection., None, 0, -2147217843), None)

Do I have to make some settings at the MS SQL Server? I just can't find
a simple example how to use adodbapi with NT authentication...

Dirk

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


Re: MS SQL Server: NT Authentication. Possible?

2006-08-18 Thread Dirk Hagemann
My windows-user has already access-permission to the database.
Thanks for the exmaple - I will try it out on monday! :-)

Enjoy your weekend!
Dirk

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


How to start more than one process at the same time?

2006-07-14 Thread Dirk Hagemann
Hi!

How can I start several jobs at the same time with python? I want to
collect data from some servers and I don't want to wait until the first
server is finished. These jobs should run parallel to save time.
What I tried is this:
os.popen('regdmp -m server1
HKEY_LOCAL_MACHINE\\Software\\Intel\\LanDesk\\VirusProtect6\\CurrentVersion\\Clients
 av_server1.txt')
os.popen('regdmp -m server2
HKEY_LOCAL_MACHINE\\Software\\Intel\\LanDesk\\VirusProtect6\\CurrentVersion\\Clients
 av_server2.txt')
os.popen('regdmp -m server3
HKEY_LOCAL_MACHINE\\Software\\Intel\\LanDesk\\VirusProtect6\\CurrentVersion\\Clients
 av_server3.txt')

I didn't get an error-message, but I also didn't get a result. No
text-file was created.
I also tried to do the same thing via batch-files, but that didn't
change anything.

Is it just not possible or what am I doing wrong?

Thanks for any help!
Dirk Hagemann

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


Countdown timer for different timezones

2006-07-06 Thread Dirk Hagemann
Hi!

I'd like to implement a countdown timer on a webite. It should show the
months, days, hours, minutes and seconds until a given date and time.
So far it's not really difficult, but this website will be used from
different time zones, what will make a difference of 10 hours, if I use
the time-information from the client. The event will take place at one
fixed moment which is worldwide the same.

Does anyone know a way to solve this time-zone-problem?

Regards and thanks for your ideas
Dirk

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


Re: string.count issue (i'm stupid?)

2006-05-22 Thread Dirk Hagemann
I think I can tell you WHY this happens, but I don't know a work-around
at the moment.
It seems as if only the following _a_ (A) are counted: a_A_a_A_

regards
Dirk

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


Re: Windows Registry Dump

2006-05-19 Thread Dirk Hagemann
@Diez: I'm not trying to hack into somebody's computer - it is about
collecting data from my company's anti-virus-parent-server. And all the
information is only available in the registry (thanks Symantec...).

@Tim, olso and Fredrik: THANKS - I will have a closer look at these
modules.

regards
Dirk

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


Re: Windows Registry Dump

2006-05-19 Thread Dirk Hagemann
Hi Tim!

I want to do some analysis (as always ;-) ) and for that reason I think
it's more practical to go trough a text-file. I can produce this
text-file also by right-click on the key (the  folder) in the registry
and select Export. There one can select Text-File and the place where
to save the text-file. This I want to be done by python automatically.

Dirk

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


Windows Registry Dump

2006-05-18 Thread Dirk Hagemann
Hi!

Does someone know how I can make a Text-Dump-File of a remote
Windows-Computer's Registry (not the whole registry - only a part of
it)?

Thanks a lot for some code or a helpful link!

regards
Dirk

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


Re: Convert Active Directory Object to string

2006-01-18 Thread Dirk Hagemann
Hi Fredrik!

I think this will help me. I just have to do the same for danish
encoding and may be some further encondings...

Thanks!
Dirk

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


Re: Convert Active Directory Object to string

2006-01-18 Thread Dirk Hagemann
Ok - this really works well for german special characters, but what to
do with all the other encodings.
What I could do is to try to vonvert it to latin-1 and if it fails I
try latin-2 and so on. But is this really necessary? Isn't there may me
a module which can do this for me and returns a string?

What I want to do in the end is the following: I get some data from
Active Directory, then I create a SQL-statement including this data and
write this into the database.

regards
Dirk

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


Convert Active Directory Object to string

2006-01-17 Thread Dirk Hagemann
Hi!

When I receive data from Microsoft Active Directory it is an
ad_object and has the type unicode. When I try to convert it to a
string I get this error:
UnicodeEncodeError: 'ascii' codec can't encode character u'\xfc' in
position 26: ordinal not in range(128)

This is caused by characters like the german ä, ö or ü.

But I (think I) need this as a string. Is there a simple solution???

regards
Dirk

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


change an element of a list

2005-09-15 Thread Dirk Hagemann
Hi!

I have a list of lists and in some of these lists are elements which I
want to change.
Here an example:
lists=[('abc',  4102,  3572), ('def',  2707, 'None'), ('ghi',  'None',
4102)]

'None' should be replaced by 0 or NULL or something else. But as far as
I know the replace function of the module string does not work for
lists.

Any ideas? Thanks for some help!

Dirk

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


Re: change an element of a list

2005-09-15 Thread Dirk Hagemann
THANKS! That works :-)

But meanwhile I found another solution that works in my case. Out of
this list of tuples I generated a SQL-Statement which is a simple
string. Then I simply checked this string for 'None'. May be too
easy...

Dirk

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


Re: Datatype of non-negative values

2005-02-10 Thread Dirk Hagemann
A result smaller than 0 should be just invalid.

I'd like to work with try and except like this:
value=20
try:
value=value-23
except:
print 'value is smaller than 23'

Now it should run into the except.

Dirk Hagemann


Larry Bates [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED]...
 What exactly do you want to happen when result
 would be negative?  I'll guess be zero:
 
 pseudocode:
 
 x=value
 x=max(x-something, 0)
 
 That way if it goes negative, it sticks to zero.
 
 Larry Bates
 
 
 Dirk Hagemann wrote:
  Hi,
  
  Is there a datatype in python which allows no negative values? I
  subtract several times something from a value and I don't want to chek
  everytime if this value is still bigger or equal 0.
  
  Thanks for help!
  Dirk Hagemann
-- 
http://mail.python.org/mailman/listinfo/python-list


Datatype of non-negative values

2005-02-09 Thread Dirk Hagemann
Hi,

Is there a datatype in python which allows no negative values? I
subtract several times something from a value and I don't want to chek
everytime if this value is still bigger or equal 0.

Thanks for help!
Dirk Hagemann
-- 
http://mail.python.org/mailman/listinfo/python-list