File and directory permissions in windows

2006-10-23 Thread ismael
Hi all

I have some problems to get the the permissions on windows. I use a simple
code that run perfectly in UNIX but give me wrong information on Windows. I
found this code searching by google:

import os
import stat

print os.stat('fichero.txt')
st = os.stat('fichero.txt')

mode = st[stat.ST_MODE]
print mode
if mode & stat.S_IREAD:   # same as stat.S_IRUSR
print "readable"
if mode & stat.S_IWRITE:  # same as stat.S_IWUSR
print "writable"
if mode & stat.S_IEXEC:   # same as stat.S_IXUSR
print "executable"

This code allways say that file is readable and writable except if is a read
only file.
Looking for a solution I found this code that use other library but the
result is the same:

import nt
import os
import sys

if (sys.platform == "win32"):
print nt.access ('c:/prueba/fichero.txt', nt.W_OK)

is there a solution for this?, another library or code? Anything that i do
wrong?
Thanks everybody.
Best regards.


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


RE: File and directory permissions in windows

2006-10-23 Thread ismael
No feel guilty because all of us have a lot of things to do and usualy we
dont have time to do it.

My objective is check if some directories exist and if the user that execute
the perl script has access to some files and directories. If one of this
checkpoints failed the execution will be aborted. If all of then finish ok
the execution will continue. It's simply this.
Those scripts will be executed on windows and linux. I start to look python
because the MS-DOS utilities were so basic and when i try to do the same
with python i found the same problem with the permissions :P Then i try
Perl and what happens? the same problem...

Thanks for all.

Best regards.

Tim Golden wrote:

> [ismael]
> 
> | I have some problems to get the the permissions on windows. I
> | use a simple code that run perfectly in UNIX but give me wrong
> | information on Windows. I found this code searching by google:
> 
> [... snip ...]
> 
> | is there a solution for this?, another library or code?
> | Anything that i do wrong?
> 
> Well, I'm certainly feeling guilty, because I've had a
> note on my TODO list since the last time this came up
> a month or so ago.
> 
> In short, Windows doesn't really map the read/write/exec
> Posix model especially logically. AFAICT, the MS CRT code
> doesn't take account of NT permissions or things like PATHEXT
> at all -- which would give you non-readable or executable.
> The traditional DOS model only supports read-only
> (and hidden/system/archived which don't apply here) so
> there's no way, eg, for any combination of flags to indicate
> can't-read-at-all.
> 
> In short, *I* need to provide that doc patch I got halfway
> through, and *you* need to find a way around whatever you're
> trying to do on Windows. Depending on what you're after, you
> might end up with some sort of try-except framework, or using
> the win32security module from the pywin32 extensions.
> 
> Feel free to post again indicating what you're trying to do
> with the stat information.
> 
> TJG
> 
> 
> This e-mail has been scanned for all viruses by Star. The
> service is powered by MessageLabs. For more information on a proactive
> anti-virus service working around the clock, around the globe, visit:
> http://www.star.net.uk
> 

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


How to get the list of all my open file(descriptor)s and locks?

2012-09-19 Thread Ismael Farfán
Hello list

>From man 2 EXECVE
"By default, file descriptors remain open across an execve()"

And from man 2 FCNTL
"Record locks are... preserved across an execve(2)."

So the question:
* If I execve a python script (from C), how can I retrieve the list of
files, and optionally the list of locks, from within the execve(d)
python process so that I can use them?


Some more info:
I'm working with exotic stuff like AIX and Solaris 10 (Windows and
linux too :) and my lowest common denominator is python 2.3.

>From a standalone test within the interpreter I'd expect to get (at
least) std(in/out/err).

If more information is needed in order to help me, please let me know.

Cheers
Ismael


-- 
Do not let me induce you to satisfy my curiosity, from an expectation,
that I shall gratify yours. What I may judge proper to conceal, does
not concern myself alone.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Passing arguments to & executing, a python script on a remote machine from a python script on local machine (using ssh ?)

2012-09-19 Thread Ismael Farfán
2012/9/19 ashish :
> Hi c.l.p folks
>
> Here is my situation
>
> 1. I have two machines. Lets call them 'local' & 'remote'.
> Both run ubuntu & both have python installed
>
> 2. I have a python script, local.py, running on 'local' which needs to pass 
> arguments ( 3/4 string arguments, containing whitespaces like spaces, etc ) 
> to a python script, remote.py running on 'remote' (the remote machine).
>
> I have the following questions:
>
> 1. What's the best way to accomplish my task ?
> I have researched quite a bit & pretty much everybody is using ssh.
> After googling a bunch, most people are using very complex workarounds to do 
> this sort of thing.
>
> I googled & found people using several libraries to accomplish ssh to remote 
> machine & execute a command on remote machine.
> paramiko ( now forked into the ssh moduke), fabric, pushy ,etc
>
> People who have used any of these libraries, which one would you recommend, 
> as the most apt (simple & easy to use, lightweight, best performance, etc) 
> for my situation ?
>
> 2. I would prefer a solution, which does NOT require the installation of 
> extra libraries on the local & remote machines.
> If installing external librar
>
> 3. Has anybody been able to do this using os.system ?
>
> I tried this
>>>> import os
>>>> os.system ("ssh remoteuser@remote python remote.py arg1 arg2 arg3")
>
> This worked, but if the arguments i tried to pass, had spaces, i was not able 
> to 'escape' the spaces.

How about something like this:
os.system ( 'ssh remoteuser@remote python remote.py "arg 1" "arg 2" "arg 3"' )

Cheers
Ismael


>
> Any & all explanations/links/code 
> snippets/thoughts/ideas/suggestions/feedback/comments/ of the Python tutor 
> community would be greatly appreciated.
>
> Thanks a ton
>
> cheers
> ashish
>
> email :
> ashish.makani
> domain:gmail.com
>
> “The only way to do great work is to love what you do. If you haven’t found 
> it yet, keep looking. Don’t settle. As with all matters of the heart, you’ll 
> know when you find it.” - Steve Jobs (1955 - 2011)
> --
> http://mail.python.org/mailman/listinfo/python-list



-- 
Do not let me induce you to satisfy my curiosity, from an expectation,
that I shall gratify yours. What I may judge proper to conceal, does
not concern myself alone.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to get the list of all my open file(descriptor)s and locks?

2012-09-19 Thread Ismael Farfán
2012/9/19 Ismael Farfán :
> Hello list
>
> From man 2 EXECVE
> "By default, file descriptors remain open across an execve()"
>
> And from man 2 FCNTL
> "Record locks are... preserved across an execve(2)."
>
> So the question:
> * If I execve a python script (from C), how can I retrieve the list of
> files, and optionally the list of locks, from within the execve(d)
> python process so that I can use them?
>
>
> Some more info:
> I'm working with exotic stuff like AIX and Solaris 10 (Windows and
> linux too :) and my lowest common denominator is python 2.3.
>
> From a standalone test within the interpreter I'd expect to get (at
> least) std(in/out/err).
>
> If more information is needed in order to help me, please let me know.
>
> Cheers
> Ismael
>
>
> --
> Do not let me induce you to satisfy my curiosity, from an expectation,
> that I shall gratify yours. What I may judge proper to conceal, does
> not concern myself alone.

It seems like I can use os.fstat to find out if a fd exists and also
get it's type and mode (I'm getting some pipes too : )

I hope it's portable across platforms, if someone knows a better
solution please let me know.

Ismael



-- 
Do not let me induce you to satisfy my curiosity, from an expectation,
that I shall gratify yours. What I may judge proper to conceal, does
not concern myself alone.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to get the list of all my open file(descriptor)s and locks?

2012-09-19 Thread Ismael Farfán
2012/9/19 Ian Kelly :
> On Wed, Sep 19, 2012 at 2:36 PM, Ismael Farfán  wrote:
>> It seems like I can use os.fstat to find out if a fd exists and also
>> get it's type and mode (I'm getting some pipes too : )
>
> Sure, because files and pipes both use the file descriptor
> abstraction.  If your process does any networking, you'll find sockets
> in there as well.
> --
> http://mail.python.org/mailman/listinfo/python-list

Seems like things will get interesting :D

Ismael


-- 
Do not let me induce you to satisfy my curiosity, from an expectation,
that I shall gratify yours. What I may judge proper to conceal, does
not concern myself alone.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to get the list of all my open file(descriptor)s and locks?

2012-09-19 Thread Ismael Farfán
2012/9/19 Christian Heimes :
>> So the question:
>> * If I execve a python script (from C), how can I retrieve the list of
>> files, and optionally the list of locks, from within the execve(d)
>> python process so that I can use them?
>
> Have a look at psutil:
>
> http://code.google.com/p/psutil/#Process_management
>
> Christian
>
> --
> http://mail.python.org/mailman/listinfo/python-list

Unfortunately  I'm not allowed to install 3rd party SW unless it's
absolutely necessary, but thanks for sharing, I'll have a look at the
arch dependent code : )

Ismael


-- 
Do not let me induce you to satisfy my curiosity, from an expectation,
that I shall gratify yours. What I may judge proper to conceal, does
not concern myself alone.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to do draw pattern with python?

2012-09-21 Thread Ismael Farfán
2012/9/21 Peter Otten <[email protected]>:
> [email protected] wrote:
>
> print "\x1b[2J\x1b[0;0H" # optional

Nice code : )

Could you dissect that weird string for us?

It isn't returning the cursor to (0,0), it's just like executing
clear(1), and looks like those line coloring scape sequences for bash.

Ismael


-- 
Do not let me induce you to satisfy my curiosity, from an expectation,
that I shall gratify yours. What I may judge proper to conceal, does
not concern myself alone.
-- 
http://mail.python.org/mailman/listinfo/python-list


potential feature "Yield in "

2022-11-15 Thread Ismael Harun
This is about a feature suggestion regarding having the ability to have 
parallel generators.  Currently you can have generators and iterators that can 
yield a single value. or a collection of values (still a single value).  But 
what if you could yield to multiple objects.  In a sense build multiple 
generators but without having to set these up as return objects.

The main concept is having a way to push values to multiple iterable objects
from the same loop or code.  We have the ability to zip multable iterables 
for use in parallel.  Why not the reverse? As in create multiple generators in 
parallel.  It's just an idea, and I haven't thought it through thoroughly nut I 
wanted to see if anyone had thoughts, critics or feedback. 

It would require not only a parser change, but also a new type which I am 
calling a Collector in my example.  A class that has a method used to receive 
new items.  Such a thing could be asynchronous.  . 

Something like:
```
def split_values(values, *collectors):
for i in values:
for n, c in enumerate(collectors, 1):
yield i**n in c


class MyCollector(list, Collector):
   def __receive__(self, value):
yield value

  
collector0 = MyCollector()
collector1 = MyCollector()

split_values(range(1,6), collector0, collector1)

for i in collector0:
print(i)
for i in collector1:
print(i)
```

Which would result in output:
```
1
2
3
4
5
1
4
9
16
25
```
-- 
https://mail.python.org/mailman/listinfo/python-list