More elegant way to obtain ACLs / permissions for windows directories than using "cacls" dos command?
Is there a standard library module in Python 2.4 (Win32) that will
return directory permissions / ACLs (e.g. users, groups, and what
rights they have)?
Otherwise, I'm faced with sending "cacls dirName" commands via os.popen
as below, and then parsing and comparing the text output.
Basically, I'd like to compare what the ACLs a directory should have
against what the actual ACLs are.
Here's what I started with:
import os # Cross-platform filesystem manipulation
rootDir = "S:\someRootDirectoryHere"
print "*** Printing DIRECTORY names beneath directory " + rootDir + "
***\n"
for dirpath, dirnames, filenames in os.walk(rootDir):
for dirNm in dirnames:
theDirPath = os.path.join(dirpath, dirNm)
print '"' + theDirPath +'"'
# cacls needs double-quotes around space-containing paths
result = os.popen("cacls " + '"' + theDirPath + '"')
# Print the security info (ACLs)for specified directory
print result.read()
Thanks.
--
http://mail.python.org/mailman/listinfo/python-list
Re: More elegant way to obtain ACLs / permissions for windows directories than using "cacls" dos command?
Thanks Roger, I'll give it a shot. Is os.walk the best way (using standard library modules) to traverse directory trees in Python 2.4 and beyond? -- http://mail.python.org/mailman/listinfo/python-list
Re: More elegant way to obtain ACLs / permissions for windows directories than using "cacls" dos command?
Could you give an example for listing security descriptors using the win32security module? I looked at the documentation but found it confusing. Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: More elegant way to obtain ACLs / permissions for windows directories than using "cacls" dos command?
> There are some examples of using the security descriptor objects in > \Lib\site-packages\win32\Demos\security. > Also, searching the Python-win32 mailing list should turn up some > more code. Thanks again Roger. -- http://mail.python.org/mailman/listinfo/python-list
pyGoogle - restrict by country doesn't seem to work
If I want to restrict search results by country, what precisely do I need to include in searchTerm variable below? I've tried: searchTerm = 'restrict:countryUS blah blah' searchTerm = ' countryUS blah blah' Neither work. What am I doing wrong? import google data = google.doGoogleSearch(searchTerm) Thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: pyGoogle - restrict by country doesn't seem to work
This worked for me: data = google.doGoogleSearch(searchTerm, restrict = 'countryUS') How does restrict results by country at Google.com? -- http://mail.python.org/mailman/listinfo/python-list
Module for creating a screenshot of a web page given a URL?
Is there a Python module that, given a URL, will grab a screenshot of the web page it goes to? I'd like to be able to feed such a module a list of URLs from a file. Thanks very much. -- http://mail.python.org/mailman/listinfo/python-list
Re: Module for creating a screenshot of a web page given a URL?
> Untestetd, but I'm pretty sure something like this will do. > If you need more control, and on windows, try pywinauto I do need it to run on Windows. I'll check out pywinauto. Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Best python module for Oracle, but portable to other RDBMSes
I'm a little confused about what's out there for database modules at: http://python.org/topics/database/modules.html What I'd like to do is use Python to access an Oracle 9.X database for exporting a series of tables into one aggregated table as a text file, for import into a mainframe database. The catch is that I'd like to write code that wouldn't need to be changed (much) if we switched from Oracle to some other RDBMS (still need to export out as a text file for import to the mainframe database. Looks like I'd probably want to use something that conforms to the DB-API 2.0. On the module list, I see DCOracle2, but it hasn't been updated since 2001. Anyone here use this module, and does it work with both Oracle 9.2 and Oracle 10g? Are there other DB-API 2.0 compliant modules I should be looking at? What are the advantages and disadvantages of the ones that can access Oracle 9.2 and Oracle 10g databases? Thanks in advance. -- http://mail.python.org/mailman/listinfo/python-list
Multiple versions of Python / PythonWin on the same machine?
I have Python 2.1 / PythonWin 2.1 installed on my machine because I need it for use with ESRI's ArcGIS Desktop software, but I want to play with a more recent version of Python. Is it safe to install more than one version of Python / PythonWin on the same machine? I don't want the latest release to wipe out the old one. -- http://mail.python.org/mailman/listinfo/python-list
Re: Best python module for Oracle, but portable to other RDBMSes
Thanks Olivier and Jonathan. Do either of you, or anyone else, know of a good open source data modeling / ER-diagram / CASE tools? I'd like to be able to build relatively simple schemas in one open source tool and be able to create a database on different platforms as needed (e.g. MySQL, PostgreSQL, Oracle, etc). Just wondering what's out there. Thanks. -- http://mail.python.org/mailman/listinfo/python-list
A bit off topic, but good web hosting for PostgreSQL/Python?
Seems like most web hosting providers support MySQL, but not PostgreSQL. I need a web hosting account that supports PostgreSQL for a particular personal project I'm working on (as well as Python, natch), since PostGIS runs only on PostgreSQL. PostGIS is a nice open source spatial database extension to PostgreSQL that allows you to store geometry in the database. Couldn't find a good PostgreSQL newsgroup so I thought I'd ask here. Did find one weird one named Mailing something or other, but that may be a gateway to a e-mail distribution list. -- http://mail.python.org/mailman/listinfo/python-list
Re: Best python module for Oracle, but portable to other RDBMSes
How about DBdesigner4 or Dia as free ER diagrammers? [EMAIL PROTECTED] wrote: > Thanks Olivier and Jonathan. > > Do either of you, or anyone else, know of a good open source data > modeling / ER-diagram / CASE tools? I'd like to be able to build > relatively simple schemas in one open source tool and be able to create > a database on different platforms as needed (e.g. MySQL, PostgreSQL, > Oracle, etc). > > Just wondering what's out there. > > Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: Best python module for Oracle, but portable to other RDBMSes
What would be the next best Oracle database module for Python next to cx_oracle? I'd like to compare two and choose one, just for the sake of seeing how two modules doing the same thing operate. Also, does installing cx_oracle create registry entries or require admin privs on a Windows XP machine? I see that cx_oracle is distributed as an EXE. Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: Best python module for Oracle, but portable to other RDBMSes
Also, what's the difference between something like cx_oracle and an ODBC module? If I were to use an ODBC module (not trying to torture myself here, I promise, but I just want to see what alternatives exist and how they work). -- http://mail.python.org/mailman/listinfo/python-list
Re: Best python module for Oracle, but portable to other RDBMSes
Thanks Gerhard and Magnus. Magnus, thanks for the references. I will follow up on those. I was messing around with the native ODBC module you mentioned (I am using Python in a Win32 environment), e.g: import dbi, odbc ...and it seems to meet my needs. The only issue I've had so far is retrieving data from Oracle when an integer has been defined like: number(p)[same thing as number(p,0) evidently This is from a database I didn't design and can't change. The problem is that the ODBC module suffixes an "L" to any integer returned that was defined as data type number(p). For example, an integer stored as: 56 will be returned as 56L. Numbers that were specified as number(p,s), the module has no problem with. Anyone know why this would happen? Incidentally, performance isn't an issue for this particular use case. -- http://mail.python.org/mailman/listinfo/python-list
Re: Best python module for Oracle, but portable to other RDBMSes
The other thing I didn't do a good job of explaining is that I want to have a layer of abstraction between the underlying RDBMS and the business logic. It's the business logic I want to use Python for, so that would stay roughly the same between RDBMS changes, if we ever have an RDBMS change. I agree that I probably have more things to worry if I was to change RDBMS vendors than what I'm describing here. -- http://mail.python.org/mailman/listinfo/python-list
PythonWin: any way to delete all objects without exiting and without doing it with "del"?
In PythonWin, is there any way to bulk-delete all objects without using "del object" for each, and without having to exit out of PythonWin? -- http://mail.python.org/mailman/listinfo/python-list
Re: PythonWin: any way to delete all objects without exiting and without doing it with "del"?
> PythonWin is just an IDE. For what reason you have to delete all objects by > yourself? Garbage collector is there for that :) I think the garbage collector is on strike. :-) Example: # 1st execution a = [1,2,3] print a >>> [1,2.3] program ends. Then I comment out a = [1,2,3] and run the program: # 2nd execution # a = [1,2,3] print a >>> [1,2,3] Same result. Why? I know that's not a great example, but it was giving me grief in the debugging process while using the ODBC module. I'd really rather not have to exit out of PythonWin each time I want to clear out all the objects I created during a script, and then subsequently comment out for future executions of a script for debugging, if that makes any sense. -- http://mail.python.org/mailman/listinfo/python-list
Problem with dbi, odbc module and Oracle 9.2 - suffixed "L" with number data type
I was messing around with the native ODBC module (I am using Python in a Win32 environment), e.g: import dbi, odbc ...and it seems to meet my needs. I'd rather use a module that comes natively with Python if it works (don't care about performance in this particular use case; just that it works). The only issue I've had so far is retrieving data from Oracle when an integer has been defined like: number(p)[same thing as number(p,0) evidently] This is from a database I didn't design and can't change. Evidently there are new ways to declare integer data types in Oracle. The problem is that the ODBC module suffixes an "L" to any integer returned that was defined as data type number(p). For example, an integer stored as: 56 will be returned as 56L. Actually, it now seems to be doing the same thing, at least in some cases, for number data types declared as number(p,s). What gives? Anyone know why this would happen? Can't use mxODBC because it's a commercial product and can't use cx_oracle at the moment because I am stuck with Python 2.1 (for ESRI geoprocessing), and there is no cx_oracle for Python 2.1 (starts with Python 2.2 and refuses to install for 2.1). I could install a later version of Python independently, but I need to be able to do the geoprocessing that 2.1 allows as well as ODBC calls to Oracle all in the same script. This means dbi,odbc seems to be my only choice. Thanks for the help so far y'all. As a former Perl devotee, I now worship at the altar of Python. -- http://mail.python.org/mailman/listinfo/python-list
ODBC module and strange date reference <...>
Been using the ODBC module for Python 2.1 (Win32) and had another question. When I return data from date columns, it's in a strange object form, e.g. (don't have the output in front of me>. What's an easy way to convert date objects into a human-readable string? I'm using this module to extract data from an Oracle database, then converting it to a flat-file for import into an old flat-file database on a mainframe. I need to be able to change the date object into something the mainframe database will recognize. Incidentally, I have just ordered: * Learning Python * Python Cookbook * Python Pocket Reference Are there any other books y'all would recommend as essential Python references and/or books for becoming fluent in Python? Thanks again. -- http://mail.python.org/mailman/listinfo/python-list
Re: Problem with dbi, odbc module and Oracle 9.2 - suffixed "L" with number data type
Great, thanks Diez! Should I just use str(n) to convert it to a format I can write out to a flat file? I'm also struggling with the strange date object format that the ODBC module returns when I fetch rows. I need to convert that to a text string in a format that a mainframe flatfile database requires. Any advice there? Diez B. Roggisch wrote: > [EMAIL PROTECTED] wrote: > > > I was messing around with the native ODBC module (I am using Python in > > a Win32 environment), e.g: > > > > import dbi, odbc > > > > ...and it seems to meet my needs. I'd rather use a module that comes > > natively with Python if it works (don't care about performance in this > > particular use case; just that it works). > > > > The only issue I've had so far is retrieving data from Oracle when an > > integer has been defined like: > > > >number(p)[same thing as number(p,0) evidently] > > > > This is from a database I didn't design and can't change. Evidently > > there are new ways to declare integer data types in Oracle. > > > > The problem is that the ODBC module suffixes an "L" to any integer > > returned that > > was defined as data type number(p). For example, an integer stored as: > > 56 will be returned as 56L. Actually, it now seems to be doing the > > same thing, at least in some cases, for number data types declared as > > number(p,s). What gives? Anyone know why this would happen? > > Well, it is a legal python umber literal. Fire up your python interpreter > and do > > >>> long(1) > 1L > > It simply says that it is a long, not an int (which means 64 rather than 32 > bits of precision I think) > > So - no need to worry. > > Diez -- http://mail.python.org/mailman/listinfo/python-list
Re: ODBC module and strange date reference <...>
Thanks Frank. Much appreciated. I will give it a go. -- http://mail.python.org/mailman/listinfo/python-list
Re: ODBC module and strange date reference <...>
Thanks Frank. Much appreciated. I will give it a go. -- http://mail.python.org/mailman/listinfo/python-list
Re: ODBC module and strange date reference <...>
Sorry for the double-thanks Frank. I'm using Python 2.1 for Win32 and import datetime fails. Does the datetime module come standard with later releases of Python? If so, which release? If not, will datetime with with Python 2.1, if it will, where can I get it? I'm still such a newbie with Python that I'm not even sure where in the directory structure modules go. My Python reference books from Amazon.com are in the mail. Thanks again for your help. -- http://mail.python.org/mailman/listinfo/python-list
Re: Best python module for Oracle, but portable to other RDBMSes
> If you actually get a suffixed L in the resulting text file, you > are using a strange way to convert your data to text. You aren't > simply printing lists or tuples are you? Then other types, such as > datetime objects will also look bizarre. (Not that the ancient > odbc would support that...) > You might want to look at the csv module for text export. Thanks Magnus. I didn't know there was a csv module. Here's how I'm getting the suffixed "L" import dbi, odbc # Import ODBC modules connectString = 'odbc_con_name/username/password' dbc = odbc.odbc(connectString)# Connect to Oracle cursor = dbc.cursor()# Create cursor sql = "select statement here..." # Define SQL statement cursor.execute(sql) # Execute sql statement allRecords = cursor.fetchall() # Fetch all returned records into a list of tuples numRecords = len(allRecords) # Get num of records returned by the query # Note: I'm leaving out the for loop for this example... # Print first record: print allRecords[0] >>> (872L, 'ACTIVE', , >> 010C2ED0>, None, '1.0.0.0', None, None, None) # Convert first tuple to a list so I have a mutable object recordList = list(allRecords[0]) # Print new list print recordList >>> [872L, 'ACTIVE', , >> 00EA1428>, None, '1.0.0.0', None, None, None] # Convert long integer to short integer (int) to get rid of the "L" recordList[0] = int(recordList[0]) # Print list with changed item. No more "L" print recordList[0] >>> [872, 'ACTIVE', , , >>> None, '1.0.0.0', None, None, None] # The End Are you saying I'm getting the "L" as an artifact of printing? -- http://mail.python.org/mailman/listinfo/python-list
Re: PythonWin: any way to delete all objects without exiting and without doing it with "del"?
Steven, does your technique fix my problem? Would that delete the objects I've created within a program if I suffix my code with it? -- http://mail.python.org/mailman/listinfo/python-list
Re: Best python module for Oracle, but portable to other RDBMSes
>[EMAIL PROTECTED] wrote: > dananrg> Are you saying I'm getting the "L" as an artifact of printing? > > No, you're getting the "L" because you're printing a long integer. If you > execute > > x = 872L > y = 872 > > at a Python prompt, x will be a long integer and y will be an integer. Long Thanks Skip. Much appreciated. -- http://mail.python.org/mailman/listinfo/python-list
Standard Python 2.4 module like "crypt" for Windows?
Is there a module available in the standard library, for Python 2.4 running on Windows, like "crypt" for Python 2.4 running on *nix machines? I need to store database passwords in a Python 2.4 script, but obviously don't want them in clear text. I'm looking for a reasonable level of security. What are some of my options? Also wondering if, for PythonWin, there is a module that will display asterisks rather than echo entered passwords in clear text. I see I have access to the getpass module, but I can't get it to work--it still echos typed-in passwords to the screen as clear text. -- http://mail.python.org/mailman/listinfo/python-list
Getting column names from a cursor using ODBC module?
Is there any way to retrieve column names from a cursor using the ODBC module? Or must I, in advance, create a dictionary of column position and column names for a particular table before I can access column values by column names? I'd prefer sticking with the ODBC module for now because it comes standard in Python. I'm using Python 2.4 at the moment. Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: Getting column names from a cursor using ODBC module?
Thanks Chris and John. Chris, this worked perfectly with the ODBC module that ships with Python Win32: > column_names = [d[0] for d in cursor.description] John, I've never heard of pyodbc but I'll have to look into it. Thanks again. Dana -- http://mail.python.org/mailman/listinfo/python-list
Re: ODBC module and strange date reference <...>
Magnus Lycka wrote: > Are you using an old version of ESRI software, or are > they shipping a product with an ancient version of Python? We're using the latest and greatest ArcGIS Desktop product, which is at release 9.1. Evidently they chose to use Python 2.1 to ensure a "silent install" when ArcGIS Desktop gets installed. I've been told the beta for ArcGIS Desktop 9.2 ships with Python 2.4, so it's safe to say the official release of 9.2 this summer will ship with Python 2.4 as well. At least that's my hope. > You can't really expect that third party product will > support Python 2.1 any longer. A lot of new software > take advantage of the new features in Python that came > in later versions. Current Python versions are also a > bit faster. I'm all for using for the latest version of Python. I'm just now learning about Python classes, and it seems like there were some significant changes at 2.2. > If I were you, I'd check with ESRI support if you can't > use a newer version of Python. I think it's possible. I think it is as well and am looking into it. Thanks again for your help Magnus. Dana -- http://mail.python.org/mailman/listinfo/python-list
Re: Problem with dbi, odbc module and Oracle 9.2 - suffixed "L" with number data type
Thanks Andrew. > I've been bugging ESRI about upgrading, and I'm sure others have too. The beta of ArcGIS Desktop 9.2 ships with Python 2.4, so I imagine the release of ArcGIS Desktop 9.2 this summer will also ship with Python 2.4. I've read threads recently on the geoprocessing / scripting support.esri.com of people using Python 2.4 successfully for geoprocessing but I've not tried to install it yet. Check out: http://forums.esri.com/Thread.asp?c=93&f=1729&t=157014 And also this support article: http://support.esri.com/index.cfm?fa=knowledgebase.techarticles.articleShow&d=26872 Let me know if you have any luck with this. Dana -- http://mail.python.org/mailman/listinfo/python-list
Spidering Hacks for Python, not Perl
O'Reilly's Spidering Hacks books terrific. One problem. All the code samples are in Perl. Nothing Pythonic. Is there a book out there for Python which covers spidering / crawling in depth? -- http://mail.python.org/mailman/listinfo/python-list
Filters like old skool Jive, Fudd, Valspeak... Text transformation in Python
I would like to learn how to roll my own filter ala early 90's filters like Jive, Fudd, Kraut, Moron, etc, that take text as an input, and re-writes the text adding general hilarity of various linguistic flavor (depending on the filter). I always loved running my philosophy papers, or anything that sounded "too dang serious" through filters. Gave me a new perspective on my own writing. Running the screenplay of the Empire Strikes Back through the Kraut filter, particularly the scene where Vader reveals Skywalker's true lineage, is amusing. No offense to good Germans everywhere. I'm sure someone could write a good "American" filter than would be a gag on American obsession with success and work, being happy 100% of the time, etc. Anyway, I'd like to see an old skool filter written in Python so I can write my own filters. There's an old prof of mine so, erm, linguistically unique, that I absolutely must write a Prof X filter to share with old college buds. I need to encapsulate / generate a model of the Prof's speech patterns for posterity and "educational purposes only" - ok, for entertainment. A fun way to learn more about Python and text processing. Any good "generators" written in Python? I'd like to roll me one of these as well; e.g. execute the program and it will create a few paragraphs of text in the jargon of a discipline, subdiscipline, subculture, etc. Anyone know what I'm talking about? Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: Filters like old skool Jive, Fudd, Valspeak... Text transformation in Python
bruno at modulix wrote: > There's a Kant generator example in Dive Into Python: > http://diveintopython.org/xml_processing/index.html Thanks Bruno! Perhaps I could modify it to throw in some Hume and Wittgenstein, mix it all up in a syntactic / semantic blender and REALLY confuse people. Word Games indeed. :-) Or throw in stuff by whichever philosopher who wrote a book called "The Meaning of Meaning", to add some metaphoric recursion. And that what be one heck of a Frankenstenian (but only 1 part Wittgensteinian) Robo-philosopher. Dana -- http://mail.python.org/mailman/listinfo/python-list
Using PythonWin32 to copy text to Windoze Clipboard for Unix-style random .sig rotator?
Can you tell I miss Unix? I want to write a Python script that, when launched, will choose a random .sig (from a list of about 30 cool ones I've devised), and store the .sig text in the Windows Clipboard, so I can then paste it into any Windows application. This way, it'll work for Outlook e-mails, Yahoo, Gmail, etc. Also, could I use Python to programmatically set key combos to do certain things? Should I buy the Python on Win32 book? Are all my answers there? Or is there a good PyWin32 FAQ where all (that I'm interested in with this particular e-mail) will be revealed? Spammity-spam, y'all. Thanks. Dana -- http://mail.python.org/mailman/listinfo/python-list
Best way to process table rows from an RDBMS
I can handle making the connections and running queries, but what's the best way to process table rows returned in Python? What about turning a table definition into an object? Just looking for ways to be efficient, since I know I will be hitting the same external RDBMS from Python and regularly processing a fixed set of tables with a certain fixed set of attribute columns. Is there something better than tuples for this? -- http://mail.python.org/mailman/listinfo/python-list
