Check a windows service

2007-01-16 Thread awel
Hi,

I'm new in python and I would like to know if it's possible to check if
a specific windows service is present and if it's possible how can I
do?

Thanks

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


Re: Check a windows service

2007-01-16 Thread awel
Sorry, but could you give me an example with a real service 'cause I've
tried this script but nothings happened, no error, nothings ; even if I
launch it in cmd prompt.

Thanks

Tim Golden a écrit :
> awel wrote:
>
> > I'm new in python and I would like to know if it's possible to check if
> > a specific windows service is present and if it's possible how can I
> > do?
>
> This is one way:
>
> http://tgolden.sc.sabren.com/python/wmi_cookbook.html#automatic_services
>
> You'd have to change that example slightly, but I
> hope the principal is clear enough. If not, ask again.
> 
> TJG

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

Re: Check a windows service

2007-01-16 Thread awel
Sorry, but could you give me an example with a real service 'cause I've
tried this script but nothings happened, no error, nothings ; even if I
launch it in cmd prompt.

Thanks

Tim Golden a écrit :
> awel wrote:
>
> > I'm new in python and I would like to know if it's possible to check if
> > a specific windows service is present and if it's possible how can I
> > do?
>
> This is one way:
>
> http://tgolden.sc.sabren.com/python/wmi_cookbook.html#automatic_services
>
> You'd have to change that example slightly, but I
> hope the principal is clear enough. If not, ask again.
> 
> TJG

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

Re: Check a windows service

2007-01-16 Thread awel
Sorry, but could you give me an example with a real service 'cause I've
tried this script but nothings happened, no error, nothings ; even if I
launch it in cmd prompt.

Thanks


Chris Mellon a écrit :
> On 16 Jan 2007 09:09:34 -0800, Tim Golden <[EMAIL PROTECTED]> wrote:
> > awel wrote:
> >
> > > I'm new in python and I would like to know if it's possible to check if
> > > a specific windows service is present and if it's possible how can I
> > > do?
> >
> > This is one way:
> >
> > http://tgolden.sc.sabren.com/python/wmi_cookbook.html#automatic_services
> >
> > You'd have to change that example slightly, but I
> > hope the principal is clear enough. If not, ask again.
> >
> > TJG
> >
>
> Here's some code cut & pasted from the demos included in the win32 module:
>
> import win32service
> import win32con
>
>
> def EnumServices():
> resume = 0
> accessSCM = win32con.GENERIC_READ
> accessSrv = win32service.SC_MANAGER_ALL_ACCESS
>
> #Open Service Control Manager
> hscm = win32service.OpenSCManager(None, None, accessSCM)
>
> #Enumerate Service Control Manager DB
>
> typeFilter = win32service.SERVICE_WIN32
> stateFilter = win32service.SERVICE_STATE_ALL
>
> statuses = win32service.EnumServicesStatus(hscm, typeFilter, stateFilter)
> for (short_name, desc, status) in statuses:
> print short_name, desc, status

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

Re: Check a windows service

2007-01-17 Thread awel
Thanks for all 'cause you've really helped me

Just one thing in the last line for the specific service, you' ve
writted :

>print service

but I think it is :

>print service.Caption


Tim Golden a écrit :
> awel wrote:
> > Sorry, but could you give me an example with a real service 'cause I've
> > tried this script but nothings happened, no error, nothings ; even if I
> > launch it in cmd prompt.
>
> Well, as that example said, it was designed to show
> automatic services which are not running. If you don't
> have any then nothing will show. I assumed you could
> use this as a starting point.
>
> To list all services try this:
>
> 
> import wmi
>
> c = wmi.WMI ()
> for service in c.Win32_Service ():
>   print service.Caption
>
> 
>
> To show a specific service:
>
> 
> import wmi
>
> c = wmi.WMI ()
> for service in c.Win32_Service (Caption="Task Scheduler"):
>   print service
> 
> 
> 
> TJG

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

how to filter files by creation date

2007-11-05 Thread awel
Hello All,

I am trying to to make a script to move all the files that has been
created at today's to another folder but my problem is the date format
that I receive from the 'os.stat  [stat.ST_CTIME]' is different from
the one that I receive from the 'datetime.date.today()'.

Does someone could help me?
Here is my script:

import os, stat, time, datetime
a= "c:\\"
filesys = os.listdir(a)
today= datetime.date.today()
def get_create_time(a):
 int_time = os.stat("c:\\")[stat.ST_CTIME]
 str_time = time.ctime(int_time)
 return str_time


#print filesys
for file in filesys:
 create_time = get_create_time(a)
 print file, create_time[-4:]
# print today

Thanks
Awel

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


Re: how to filter files by creation date

2007-11-06 Thread awel
On 6 nov, 09:00, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
> On Mon, 05 Nov 2007 23:33:16 -0800, awel wrote:
> > I am trying to to make a script to move all the files that has been
> > created at today's to another folder but my problem is the date format
> > that I receive from the 'os.stat  [stat.ST_CTIME]' is different from
> > the one that I receive from the 'datetime.date.today()'.
>
> Build a `datetime.date` object from the timestamp you get from the stat
> call:
>
> In [438]: !touch test.py
>
> In [439]: datetime.date.fromtimestamp(os.stat('/home/bj/test.py').st_ctime)
> Out[439]: datetime.date(2007, 11, 6)
>
> Ciao,
> Marc 'BlackJack' Rintsch

Could you explain a little more because I am new in scripting?
Thanks
Awel

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


Re: how to filter files by creation date

2007-11-06 Thread awel
On 6 nov, 11:27, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
> On Tue, 06 Nov 2007 01:45:02 -0800, awel wrote:
> > On 6 nov, 09:00, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote:
> >> On Mon, 05 Nov 2007 23:33:16 -0800, awel wrote:
> >> > I am trying to to make a script to move all the files that has been
> >> > created at today's to another folder but my problem is the date format
> >> > that I receive from the 'os.stat  [stat.ST_CTIME]' is different from
> >> > the one that I receive from the 'datetime.date.today()'.
>
> >> Build a `datetime.date` object from the timestamp you get from the stat
> >> call:
>
> >> In [438]: !touch test.py
>
> >> In [439]: datetime.date.fromtimestamp(os.stat('/home/bj/test.py').st_ctime)
> >> Out[439]: datetime.date(2007, 11, 6)
>
> >> Ciao,
> >> Marc 'BlackJack' Rintsch
>
> > Could you explain a little more because I am new in scripting?
>
> Not really.  I showed you the call I made and the result I got.  How can I
> be more clear and precise!?
>
> Ciao,
> Marc 'BlackJack' Rintsch- Masquer le texte des messages précédents -
>
> - Afficher le texte des messages précédents -

Ok but I run in Windows and I cannot understand your '!touch test.py'

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

How to replace the two last digits from an xml file?

2009-03-06 Thread awel
Hi,

I am trying to get a value from an xml file, increment it by 1,
replace by the new value and write another xml with the new value
inside.

I have found this code to get the line and it works but I have to do
everything manualy:

import re
lines = open("c:\\File1.xml").readlines()
for i in range(len(lines)):
if re.search('national.number', lines[i]):
lines[i] = lines[i].replace
('01aaa02','01aaa03')
open("File2.xml","w").writelines(lines)

The goal I am trying to reach is to create 30 different xml.

Could someone help me?

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