[python-win32] python-win32 Digest, Vol 136, Issue 6

Anis Liyana anisliyana107 at gmail.com
Mon Jul 21 03:59:26 CEST 2014


Hello,
Would appreciate any help regarding my problem.

Problem:
I am currently on a project for back up server with python script.
The project is actually arise from problem whereby when I need to back up
my server (Windows Server 2003), I usually use Robocopy but, when I copy
the folders from server 1 to server 2, it doesn't copy the user and group
access as well. Thus, I need to manually configure the users and groups
permission for each of the folders. I decided to try Python scripting as
part of the solution but I'm novice with Python and windows active
directory as well. I'm not sure how to copy the users and groups in active
directory.

I browse through the website and found python-win32, I would like to try
it, but since I'm not familiar so I'm not sure how to get it done. So far,
I only able to code the Python scripting on copying the folders. I hope
that I can proceed with users permission as well.

I am hoping for you knowledge & experienced and greatly appreciate any
help.
Thanks.

Hi,
regarding the problem, I have try various Robocopy command with security
but it doesn't work as what I wanted. I have found this website
https://zakird.com/pyad/pyad.html but I'm not really sure how should I code
it since I'm not really familiar. What I would like to do is basically like
this:
- connect to AD
- create AD object that holds the users and groups
- the object will loop through the list of users and groups in AD
- it will copy the users and groups permission.

I hope that anyone can help me. Thanks.


On Sat, Jul 19, 2014 at 10:06 AM, <python-win32-request at python.org> wrote:

> Send python-win32 mailing list submissions to
>         python-win32 at python.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
>         https://mail.python.org/mailman/listinfo/python-win32
> or, via email, send a message with subject or body 'help' to
>         python-win32-request at python.org
>
> You can reach the person managing the list at
>         python-win32-owner at python.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of python-win32 digest..."
>
>
> Today's Topics:
>
>    1. Re: Problem passing array by reference (Tim Roberts)
>    2. Re: Problem passing array by reference (Marco Nawijn)
>    3. Re: Problem passing array by reference (Marco Nawijn)
>    4. PythonWin on linux under wine (Peter Fraser)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Fri, 18 Jul 2014 09:26:34 -0700
> From: Tim Roberts <timr at probo.com>
> To: "python-win32 at python.org" <python-win32 at python.org>
> Subject: Re: [python-win32] Problem passing array by reference
> Message-ID: <53C94ABA.1020103 at probo.com>
> Content-Type: text/plain; charset="utf-8"
>
> Marco Nawijn wrote:
> > An update on where I am at the moment. I managed to find the library that
> > holds the definition for the GetComponents call. When I run makepy on
> > this library I get:
> >
> > def GetComponents(self, oAxisComponentsArray=defaultNamedNotOptArg):
> > return self._ApplyTypes_(1611005953, 1, (24, 0), ((8204, 3),),
> > u'GetComponents', None,oAxisComponentsArray)
>
> For what it's worth, the (24,0) means the function returns "void", and
> (8204,3) means the parameter is an IN/OUT parameter that is an array of
> variants.
>
> Given that, I'm a little confused as to why your original test -- where
> you passed the list of 12 items -- didn't work.  As an experiment, you
> could try changing that to say (8204,11), which means "in/out and this
> is the return value", but I'm not hopeful.
>
> We may need to get Mark Hammond involved in this.  He has more
> in-the-trenches experience here than anyone.
>
>
>
> > Afterwards I tried to interact with it as follows:
> >
> > >>> from comtypes.client import CreateObject
> > >>> app = CreateObject('Catia.Application')
> > >>> app.Visible = True
> > >>> # I then interactively open a document in the application
> > >>> p1 = app.Documents.Item(2)
> > >>> p1
> > <POINTER(Document) ptr=0x577f24 at 4049490>
> >
> > So again, I get the "wrong" document type. If I do the same
> > but using late binding (by providing the "dynamic=True"
> > parameter) I get the following:
> > >>> p1
> > <comtypes.client.lazybind.Dispatch object at 0x028387B0>
>
> Have you tried calling GetComponents with this object?  This is a
> late-bound object, which means it fetches the names of the methods and
> properties on the fly.
>
> --
> Tim Roberts, timr at probo.com
> Providenza & Boekelheide, Inc.
>
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <
> http://mail.python.org/pipermail/python-win32/attachments/20140718/17055f87/attachment-0001.html
> >
>
> ------------------------------
>
> Message: 2
> Date: Fri, 18 Jul 2014 19:28:25 +0200
> From: Marco Nawijn <nawijn at gmail.com>
> To: Tim Roberts <timr at probo.com>, Tim Roberts <timr at probo.com>;
>         python-win32 at python.org
> Cc: "python-win32 at python.org" <python-win32 at python.org>
> Subject: Re: [python-win32] Problem passing array by reference
> Message-ID: <20140718192825.158e8965 at mars>
> Content-Type: text/plain; charset=US-ASCII
>
> On Fri, 18 Jul 2014 09:26:34 -0700
> Tim Roberts <timr at probo.com> wrote:
>
> > Marco Nawijn wrote:
> > > An update on where I am at the moment. I managed to find the
> > > library that holds the definition for the GetComponents call. When
> > > I run makepy on this library I get:
> > >
> > > def GetComponents(self, oAxisComponentsArray=defaultNamedNotOptArg):
> > > return self._ApplyTypes_(1611005953, 1, (24, 0), ((8204, 3),),
> > > u'GetComponents', None,oAxisComponentsArray)
> >
> > For what it's worth, the (24,0) means the function returns "void", and
> > (8204,3) means the parameter is an IN/OUT parameter that is an array
> > of variants.
> >
> > Given that, I'm a little confused as to why your original test --
> > where you passed the list of 12 items -- didn't work.  As an
> > experiment, you could try changing that to say (8204,11), which means
> > "in/out and this is the return value", but I'm not hopeful.
> >
> > We may need to get Mark Hammond involved in this.  He has more
> > in-the-trenches experience here than anyone.
> >
> >
> >
> > > Afterwards I tried to interact with it as follows:
> > >
> > > >>> from comtypes.client import CreateObject
> > > >>> app = CreateObject('Catia.Application')
> > > >>> app.Visible = True
> > > >>> # I then interactively open a document in the application
> > > >>> p1 = app.Documents.Item(2)
> > > >>> p1
> > > <POINTER(Document) ptr=0x577f24 at 4049490>
> > >
> > > So again, I get the "wrong" document type. If I do the same
> > > but using late binding (by providing the "dynamic=True"
> > > parameter) I get the following:
> > > >>> p1
> > > <comtypes.client.lazybind.Dispatch object at 0x028387B0>
> >
> > Have you tried calling GetComponents with this object?  This is a
> > late-bound object, which means it fetches the names of the methods and
> > properties on the fly.
> >
>
>
>
> ------------------------------
>
> Message: 3
> Date: Fri, 18 Jul 2014 21:17:11 +0200
> From: Marco Nawijn <nawijn at gmail.com>
> To: Tim Roberts <timr at probo.com>, "python-win32 at python.org"
>         <python-win32 at python.org>
> Subject: Re: [python-win32] Problem passing array by reference
> Message-ID:
>         <CA+pnd0=
> DZYPR1beWNViFnir5iV9i2-hmpKXB3HYhjs7f2n2cKA at mail.gmail.com>
> Content-Type: text/plain; charset="utf-8"
>
> Dear all,
>
> Sorry for the noise on the list. Epic fail of my freshly configured mail
> client.
>
> Marco
>
>
> On Fri, Jul 18, 2014 at 7:28 PM, Marco Nawijn <nawijn at gmail.com> wrote:
>
> > On Fri, 18 Jul 2014 09:26:34 -0700
> > Tim Roberts <timr at probo.com> wrote:
> >
> > > Marco Nawijn wrote:
> > > > An update on where I am at the moment. I managed to find the
> > > > library that holds the definition for the GetComponents call. When
> > > > I run makepy on this library I get:
> > > >
> > > > def GetComponents(self, oAxisComponentsArray=defaultNamedNotOptArg):
> > > > return self._ApplyTypes_(1611005953, 1, (24, 0), ((8204, 3),),
> > > > u'GetComponents', None,oAxisComponentsArray)
> > >
> > > For what it's worth, the (24,0) means the function returns "void", and
> > > (8204,3) means the parameter is an IN/OUT parameter that is an array
> > > of variants.
> > >
> > > Given that, I'm a little confused as to why your original test --
> > > where you passed the list of 12 items -- didn't work.  As an
> > > experiment, you could try changing that to say (8204,11), which means
> > > "in/out and this is the return value", but I'm not hopeful.
> > >
> > > We may need to get Mark Hammond involved in this.  He has more
> > > in-the-trenches experience here than anyone.
> > >
> > >
> > >
> > > > Afterwards I tried to interact with it as follows:
> > > >
> > > > >>> from comtypes.client import CreateObject
> > > > >>> app = CreateObject('Catia.Application')
> > > > >>> app.Visible = True
> > > > >>> # I then interactively open a document in the application
> > > > >>> p1 = app.Documents.Item(2)
> > > > >>> p1
> > > > <POINTER(Document) ptr=0x577f24 at 4049490>
> > > >
> > > > So again, I get the "wrong" document type. If I do the same
> > > > but using late binding (by providing the "dynamic=True"
> > > > parameter) I get the following:
> > > > >>> p1
> > > > <comtypes.client.lazybind.Dispatch object at 0x028387B0>
> > >
> > > Have you tried calling GetComponents with this object?  This is a
> > > late-bound object, which means it fetches the names of the methods and
> > > properties on the fly.
> > >
> >
> >
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <
> http://mail.python.org/pipermail/python-win32/attachments/20140718/b9b807d8/attachment-0001.html
> >
>
> ------------------------------
>
> Message: 4
> Date: Sat, 19 Jul 2014 13:02:26 +1200
> From: Peter Fraser <pfraser at spatialmedia.com>
> To: python-win32 at python.org
> Subject: [python-win32] PythonWin on linux under wine
> Message-ID: <53C9C3A2.1070104 at spatialmedia.com>
> Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>
> I have tried and failed to like another Python IDE  -including the $$ ones.
>
>   They all feel like they have 'static language envy'.
>
>   PythonWin does the best job of being an IDE for a *dynamic* language
> IMO (largely due to the cunning 'psuedo-shell', and also dynamic lookup
> for 'completion' etc).
>
> SO
>
>   I find myself installing PythonWin under Wine   -although it feels
> like a somewhat unnatural act.
>
>
>
> 1. A small fix (in case someone else tries it).
> ======================================
>
> The install on Wine  goes fine  (Specifically: Python 2.7.8 win32 from
> msi installer, and  then pywin32-219.win32-py2.7.exe  -on Mint 17 both
> x64 and 32 bit machines)
>
> -but when launching PythonWin   I get an error:
>
> unsupported operand type(s) for |: 'int' and 'NoneType'
>
> ..at line 91 of keycodes.py (which lives in
> c:/Python27/Lib/site-packages/pythonwin/pywin/scintilla)
>
> My fix was simply to edit keycodes.py and change:
>
> from
>
> return vk, flags | this_flags
>
> to
>
> return vk, flags | (this_flags or 0)
>
> I was too lazy to work out why vk, this_flags = get_vk(toks[-1]) returns
> None in the second item.
>
> If someone wanted to make this change (or a better one) the PythonWin
> IDE would at least start under Wine.
>
>
>
> 2. A workaround
> ================
> I can't seem to enable the debugging toolbar *but* if I (try to) check
> it,*and restart*  -it is there.
>
>
>
> 3. Does anyone have any other warnings/fixes/'run away' advice etc?
> =========================================================
>
> Is PythonWin under wine a known bad plan? A world of pain for serious
> development, perhaps? Any wisdom appreciated..
>
>
>
> Pete
>
>
>
>
>
>
>
>
>
>
>
> ------------------------------
>
> Subject: Digest Footer
>
> _______________________________________________
> python-win32 mailing list
> python-win32 at python.org
> https://mail.python.org/mailman/listinfo/python-win32
>
>
> ------------------------------
>
> End of python-win32 Digest, Vol 136, Issue 6
> ********************************************
>



-- 

Anis Liyana Abdul Rahman
Bachelor (Hons) Information Communication & Technology
Universiti Teknologi PETRONAS,
Bandar Seri Iskandar,
31750 Tronoh,
Perak Darul Ridzuan, Malaysia.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20140721/91ec7c15/attachment-0001.html>


More information about the python-win32 mailing list