Re: How to run a python script twice randomly in a day?

2013-05-19 Thread Jason Friedman
>How to run a python script twice randomly in a day? Actually I want to run > my script randomly in a day and twice only I can think of two basic approaches. One, use crontab or some other similar functionality to call it exactly twice. Two, use crontab or some other similar functionality to

Re: suppress newlines in my script

2013-05-24 Thread Jason Friedman
> Here are two lines from the CSV file: > ,,172.20.{0}.0/27,172.20.{0}.32/27,172.20.{0}.64/27,29,172.20.{0}.96/27172.21.{0}.0/27,172.21.{0}.32/27,172.21.{0}.64/27,29,172.21.{0}.96/27 > GW:,,172.20.{0}.1,172.20.{0}.33,172.20.{0}.65,,172.20.{0}.97,,GW:,,172.21.{0}.1,172.21.{0}.33,172.21.{0}.65,,1

Re: python-django for dynamic web survey?

2013-06-18 Thread Jason Friedman
> Hi guys! > > Please help me with your advices and ideas. > > I need to create a web survey that will dynamically (randomly) select > questions and descriptions from a dataset, present them to users, collect > their answers and store them back in the dataset. (Every user gets > different set of qu

Finding all instances of a string in an XML file

2013-06-20 Thread Jason Friedman
I have XML which looks like: The "Property X" string appears twice times and I want to output the "path" that leads to all such appearances. In this case the output would be: LEVEL_1 {}, LEVEL_2 {"ATTR": "hello"}, ATTRIBUTE {"NAME": "Property X",

Re: Finding all instances of a string in an XML file

2013-06-21 Thread Jason Friedman
Thank you Peter and Dieter, will give those thoughts a try and report back. -- http://mail.python.org/mailman/listinfo/python-list

Re: Finding all instances of a string in an XML file

2013-06-23 Thread Jason Friedman
> xml = """ > > > > > > > > > > > > > > """ > > import xml.etree.ElementTree as etree > > tree = etree.fromstring(xml) > > def walk(elem, path, token): > path += (elem,) > if token in elem.attrib.values(): > yield path > for child i

Re: FACTS: WHY THE PYTHON LANGUAGE FAILS.

2013-06-27 Thread Jason Friedman
> I was hoping to have a good laugh. :| > > Although I wouldn't call it hostile. > > I think the python community is being educated in how to spam and troll at > the same time. > It is possible the OP has a mental disease, which is about as funny as heart disease and cancer and not blameworthy.

Re: Regular expression negative look-ahead

2013-07-01 Thread Jason Friedman
Found this: http://stackoverflow.com/questions/13871833/negative-lookahead-assertion-not-working-in-python . This pattern seems to work: pattern = re.compile(r"^(?!.*(CTL|DEL|RUN))") But I am not sure why. On Mon, Jul 1, 2013 at 5:07 PM, Jason Friedman wrote: > I have table

Regular expression negative look-ahead

2013-07-02 Thread Jason Friedman
I have table names in this form: MY_TABLE MY_TABLE_CTL MY_TABLE_DEL MY_TABLE_RUN YOUR_TABLE YOUR_TABLE_CTL YOUR_TABLE_DEL YOUR_TABLE_RUN I am trying to create a regular expression that will return true for only these tables: MY_TABLE YOUR_TABLE I tried these: pattern = re.compile(r"_(?!(CTL|DEL|R

Re: Regular expression negative look-ahead

2013-07-03 Thread Jason Friedman
> Huh, did not realize that endswith takes a list. I'll remember that in > the future. > > This need is actually for http://schemaspy.sourceforge.net/, which allows > one to include only tables/views that match a pattern. > > Either there is a bug in Schemaspy's code or Java's implementation of >

Re: Regular expression negative look-ahead

2013-07-03 Thread Jason Friedman
n Kelly wrote: > On Mon, Jul 1, 2013 at 8:27 PM, Jason Friedman wrote: > > Found this: > > > http://stackoverflow.com/questions/13871833/negative-lookahead-assertion-not-working-in-python > . > > > > This pattern seems to work: > > pattern = re.compile(r"

Re: Editor Ergonomics [was: Important features for editors]

2013-07-08 Thread Jason Friedman
I am right-handed and use a lefty-mouse about 50% of the time. It was difficult at first, now I'm almost as fast lefty as righty. As has been stated by others, changing the muscles being used reduces the impact on any one of them. -- http://mail.python.org/mailman/listinfo/python-list

Concurrent writes to the same file

2013-07-10 Thread Jason Friedman
Other than using a database, what are my options for allowing two processes to edit the same file at the same time? When I say same time, I can accept delays. I considered lock files, but I cannot conceive of how I avoid race conditions. -- http://mail.python.org/mailman/listinfo/python-list

Re: Concurrent writes to the same file

2013-07-11 Thread Jason Friedman
> > https://bitbucket.org/cameron_simpson/css/src/374f650025f156554a986fb3fd472003d2a2519a/lib/python/cs/fileutils.py?at=default#cl-408 > > That looks like it will do the trick for me, thank you Cameron. -- http://mail.python.org/mailman/listinfo/python-list

Re: Critic my module

2013-07-27 Thread Jason Friedman
> > >I made a Python3 module that allows users to use certain Linux shell > commands from Python3 more easily than using os.system(), > subprocess.Popen(), or subprocess.getoutput(). This module (once placed > with the other modules) can be used like this > > Looks similar to https://pypi.pytho

Read STDIN as bytes rather than a string

2012-06-18 Thread Jason Friedman
I tried this: Python 3.2.2 (default, Feb 24 2012, 20:07:04) [GCC 4.6.1] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import sys >>> import io >>> fh = io.open(sys.stdin) Traceback (most recent call last): File "", line 1, in TypeError: invalid file: <_io.

Re: Read STDIN as bytes rather than a string

2012-06-18 Thread Jason Friedman
> sys.stdin wraps a buffered reader which itself wraps a raw file reader. > sys.stdin > <_io.TextIOWrapper name='' mode='r' encoding='UTF-8'> sys.stdin.buffer > <_io.BufferedReader name=''> sys.stdin.buffer.raw > <_io.FileIO name='' mode='rb'> > > You should read from sys.stdin.buffe

Re: Read STDIN as bytes rather than a string

2012-06-18 Thread Jason Friedman
Which leads me to another question ... how can I debug these things? $ echo 'hello' | python3 -m pdb ~/my-input.py > /home/jason/my-input.py(2)() -> import sys (Pdb) *** NameError: name 'hello' is not defined -- http://mail.python.org/mailman/listinfo/python-list

Re: simpler increment of time values?

2012-07-04 Thread Jason Friedman
> Hi all, > I'd like to ask about the possibilities to do some basic manipulation > on timestamps - such as incrementing a given time (hour.minute - > string) by some minutes. > Very basic notion of "time" is assumed, i.e. dateless, > timezone-unaware, DST-less etc. > I first thought, it would be p

Re: Search and replace text in XML file?

2012-07-27 Thread Jason Friedman
> I'm looking to search an entire XML file for specific text and replace that > text, while maintaining the structure of the XML file. The text occurs within > multiple nodes throughout the file. > I basically need to replace every occurrence C:\Program Files with C:\Program > Files (x86), regar

Re: Dumping all the sql statements as backup

2012-08-30 Thread Jason Friedman
>> I have some long running processes that do very long simulations which >> at the end need to write things on a database. >> >> At the moment sometimes there are network problems and we end up with >> half the data on the database. >> >> The half-data problem is probably solved easily with sessio

Re: Python newbie here! No module named settings

2012-09-07 Thread Jason Friedman
>> I was trying to use Python wrapper for Google Charts API and was >> tweaking the examples. >> https://github.com/gak/pygooglechart/raw/master/examples/pie.py >> >> This is the script which I was trying. >> >> And the python interpreter gives the following error: >> import settings >> ImportE

Re: simple client data base

2012-09-08 Thread Jason Friedman
>>Mark R Rivet wrote: >>> Hello all, I am learning to program in python. I have a need to make a >>> program that can store, retrieve, add, and delete client data such as >>> name, address, social, telephone number and similar information. This >>> would be a small client database for my wife who h

Re: submit jobs on multi-core

2012-09-12 Thread Jason Friedman
>>> I have a python script in which I have a list of files to input one by one >>> and for each file I get a number as an output. >>> I used for loop to submit the file to script. >>> My script uses one file at a time and returns the output. >>> >>> My computers has 8 cores. >>> Is there any way th

Re: using text file to get ip address from hostname

2012-09-12 Thread Jason Friedman
> i need to get an ip address from list of hostnames which are in a textfile. > > this is what i have so far > -- > #!/usr/bin/env python > #Get the IP Address > > import socket > hostname = 'need it to read from a text file' >

Re: datetime issue

2012-09-15 Thread Jason Friedman
> # get some enviromental values > locale.setlocale(locale.LC_ALL, 'el_GR') > date = datetime.datetime.now().strftime( '%y-%m-%d %H:%M:%S' ) > > although iam setting greek as locale the time is 8 hours before, like in > texas, us > How can i change this to save the correct Greek time in variable

Re: 'indent'ing Python in windows bat

2012-09-18 Thread Jason Friedman
> I'm converting windows bat files little by little to Python 3 as I find time > and learn Python. > The most efficient method for some lines is to call Python like: > python -c "import sys; sys.exit(3)" > > How do I "indent" if I have something like: > if (sR=='Cope'): sys.exit(1) elif (sR=='Perfo

Re: Programming Issues

2012-09-19 Thread Jason Friedman
> Ask the user for the amount of change expressed in cents. Your program must > compute and display the number of half-dollars, quarters, dimes, nickels, > and pennies to be returned. > Return as many half-dollars as possible, then quarters, dimes, nickels, and > pennies, in that order. > Your prog

Re: Article on the future of Python

2012-09-27 Thread Jason Friedman
> Fair enough, but it's the M in the LAMP stack I object to. I'd much > rather have P. +1 -- http://mail.python.org/mailman/listinfo/python-list

parse an environment file

2012-09-30 Thread Jason Friedman
$ crontab -l * * * * * env This produces mail with the following contents: HOME=/home/spjsf LOGNAME=spjsf PATH=/usr/bin:/bin PWD=/home/spjsf SHELL=/bin/sh SHLVL=1 USER=spjsf _=/usr/bin/env On the other hand $ env produces about 100 entries, most of which are provided by my .bashrc; cron provid

Re: parse an environment file

2012-10-01 Thread Jason Friedman
> I want my python 3.2.2 script, called via cron, to know what those > additional variables are. How? Thank you for the feedback. A crontab line of * * * * * . /path/to/export_file && /path/to/script.py does indeed work, but for various reasons this approach will not always be available to me.

Re: parse an environment file

2012-10-02 Thread Jason Friedman
> Ah, fair enough. Well, since you're using the full range of bash > functionality, the only viable way to parse it is with bash itself. > I'd recommend going with the version you have above: > >> * * * * * . /path/to/export_file && /path/to/script.py > > Under what circumstances is this not an opt

Re: parse an environment file

2012-10-06 Thread Jason Friedman
> The only canned solution for parsing a bash script is bash. Think > about it the other way around: If you wanted to have a Python variable > made available to a bash script, the obvious thing to do is to invoke > Python. It's the same thing. I scratched my own itch: http://code.activestate.com/r

Re: notmm is dead!

2012-10-07 Thread Jason Friedman
>> It was a _joke_ referring to Michael Torrie's email addressing the >> 8 Dihedral bot _as if it was a person_. > > Well it would be useful to probe the bot's parameters... Five eights is a busy bot: http://www.velocityreviews.com/forums/t806110-p8-ok-lets-start-real-programming-in-c-for-prob

Re: Interest in seeing sh.py in the stdlib

2012-10-21 Thread Jason Friedman
> I'm interested in making sh.py more accessible to help bring Python forward > in the area of shell scripting, so I'm interested in seeing if sh would be > suitable for the standard library. Is there any other interest in something > like this? Pretty slick. My only concern is portability, are

Re: Split single file into multiple files based on patterns

2012-10-23 Thread Jason Friedman
> I have a text file like this > > A1980JE3937 2732 4195 12.527000 > A1980JE3937 3465 9720 22.00 > A1980KK18700010 186 3366 4.78 > A1980KK18700010 30 186 1.285000 > A1980KK18700010 30 185 4.395000 > A1980KK18700010 185 186 9.00 > A1980KK18700010 25 30 3.493000 > > I want to spli

Re: Split single file into multiple files based on patterns

2012-10-23 Thread Jason Friedman
On Tue, Oct 23, 2012 at 9:01 PM, satyam wrote: > I have a text file like this > > A1980JE3937 2732 4195 12.527000 > A1980JE3937 3465 9720 22.00 > A1980JE3937 1853 3278 12.50 > A1980JE3937 2732 2732 187.50 > A1980JE3937 19 4688 3.619000 > A1980KK18700010 30 186 1.285

Re: SSH Connection with Python

2012-10-25 Thread Jason Friedman
> how can i create a SSH-Connection with python? I have to send some commands > to the remote host and parse their answers. Consider also the sh module: http://amoffat.github.com/sh/tutorials/2-interacting_with_processes.html. -- http://mail.python.org/mailman/listinfo/python-list

Re: Migrate from Access 2010 / VBA

2012-11-22 Thread Jason Friedman
> I am the lone developer of db apps at a company of 350+ employees. Everything > is done in MS Access 2010 and VBA. I'm frustrated with the limitations of > this platform and have been considering switching to Python. I've been > experimenting with the language for a year or so, and feel comfor

Re: ANNOUNCE: Thesaurus - a recursive dictionary subclass using attributes

2012-12-10 Thread Jason Friedman
> Thesaurus is a new a dictionary subclass which allows calling keys as > if they are class attributes and will search through nested objects > recursively when __getitem__ is called. Good stuff. You might consider: 1) Licensing under an OSI-approved license (http://opensource.org/licenses/index.

Re: Trying to make a basic Python score counter in a game... will not count.

2012-12-17 Thread Jason Friedman
> if you're interested in learning Python and/or game programming in > Python, you might want to take a look at http://inventwithpython.com/ And https://www.coursera.org/course/interactivepython. -- http://mail.python.org/mailman/listinfo/python-list

ImportError: /usr/local/lib/python3.2/dist-packages/OpenSSL/SSL.cpython-32mu.so: undefined symbol: SSLv2_method

2012-12-27 Thread Jason Friedman
Hello, I downloaded: https://launchpad.net/pyopenssl/main/0.11/+download/pyOpenSSL-0.11.tar.gz Then: $ python3 setup.py build $ sudo python3 setup.py install Then: $ python3 -c "from OpenSSL import SSL" Traceback (most recent call last): File "", line 1, in File "OpenSSL/__init__.py", line 4

Re: How do you call a function several times in this context??

2013-01-06 Thread Jason Friedman
> def double(value): > result > return result > > number=input('type a number') > print (double(int(number))) > I think what was meant: def double(value): result = 2 * value return result -- http://mail.python.org/mailman/listinfo/python-list

Re: [Offtopic] Line fitting [was Re: Numpy outlier removal]

2013-01-08 Thread Jason Friedman
> Statistical analysis is a huge science. So is lying. And I'm not sure > most people can pick one from the other. Chris, your sentence causes me to think of Mr. Twain's sentence, or at least the one he popularized: http://www.twainquotes.com/Statistics.html. -- http://mail.python.org/mailman/lis

Re: [Offtopic] Line fitting [was Re: Numpy outlier removal]

2013-01-08 Thread Jason Friedman
> Statistical analysis is a huge science. So is lying. And I'm not sure > most people can pick one from the other. Chris, your sentence causes me to think of Mr. Twain's sentence, or at least the one he popularized: http://www.twainquotes.com/Statistics.html. -- http://mail.python.org/mailman/lis

Re: ANN: Python training "text movies"

2013-01-13 Thread Jason Friedman
> That is right; I would also add that it may be overwhelming for a newbie > to be reading through a large "wall of text" -- here you have blank > space after the current paragraph so the attention is focused even more > on the last few lines. > > Additionally, since instructions scroll automatical

Re: Parent module adsite.adsiteviews.mainhanlder does not exist

2013-01-20 Thread Jason Friedman
> I created a django project using django 1.4.2. There is one 'app'(adsite) in > this project. And It works. But when I copied some 'py' files into the 'app' > folder, I got "Parent module adsite.adsiteviews.mainhanlder does not exist." > Should I register the new files to __init__ in the 'app'?

Re: Cancel threads after timeout

2013-01-26 Thread Jason Friedman
> Sometimes it happens that a query on one of the database servers > takes longer than expected and impedes the generation of this report > (that's right, the queries are ran sequential). What I am trying to > achieve is to parallelize the queries on each database server and to be > able to cancel

Re: Cancel threads after timeout

2013-01-27 Thread Jason Friedman
> On 26Jan2013 09:48, Matt Jones wrote: > | It sounds like your real problem is with your SQL query... Is that part of > | this problem under your control? Can you break the query into smaller, > | quicker, pieces that you can run in a reasonable amount of time? > > Another option to investigate

python zipfile v. native unzip

2012-01-31 Thread Jason Friedman
Does Python 2.7's zipfile module use its own algorithm or does it leverage the zip/unzip libraries that exist on the host? I ask because my host's native unzip program cannot handle files that, when unzipped, are larger than 2GB. Will using Python 2.7 get around this limitation? -- http://mail.p

Installing pypi package twice

2012-01-31 Thread Jason Friedman
My system's default python is 2.6.5. I have separately installed 3.2.2 at /opt/python. I downloaded python-daemon-1.5.5 and installed with: $ tar xzf python-daemon-1.5.5 $ cd python-daemon-1.5.5 $ python setup.py build $ sudo python setup.py install How would I also install this package for 3.2.2

Installing pypi package twice

2012-01-31 Thread Jason Friedman
My system's default python is 2.6.5. I have also installed python3.2 at /opt/python. I installed a pypi package for 2.6.5 with: $ tar xzf package.tar.gz $ cd package $ python setup.py build $ sudo python setup.py install How can I also install this same package for 3.2? (I am assuming this packa

Use logging level across application and modules

2012-02-02 Thread Jason Friedman
Base module: http://pastebin.com/nQCG5CRC Another module: http://pastebin.com/FFzCCjwG Application: http://pastebin.com/370cWJtT I have a module that will provide base functionality, such as logging and authentication. I have other specialized modules that provide additional functionality. One

Re: Use logging level across application and modules

2012-02-02 Thread Jason Friedman
> Base module:  http://pastebin.com/nQCG5CRC > Another module:  http://pastebin.com/FFzCCjwG > Application:  http://pastebin.com/370cWJtT > > I have a module that will provide base functionality, such as logging > and authentication. > I have other specialized modules that provide additional > func

parse a profile

2012-02-18 Thread Jason Friedman
I have a file I use for shell scripts that looks like this: export VAR1=/path/to/dir export VAR2=7 export VAR3=${VAR1}/further/path # comment . /another/file And a file /another/file: export VAR4=database-name Is there an existing package that will read such a file and return a dictionary like t

HTTP logging

2012-02-20 Thread Jason Friedman
I am logging to HTTP: logger.addHandler(logging.handlers.HTTPHandler(host, url)) Works great, except if my HTTP server happens to be unavailable: socket.error: [Errno 111] Connection refused Other than wrapping all my logger.log() calls in try/except blocks, is there a way to skip logging to th

SSL on 3.2.2

2012-02-24 Thread Jason Friedman
Hello, attempting to build from source on Ubuntu 11.10. Before running ./configure I had set this in Modules/Setup.dist: SSL=/usr/lib/ssl _ssl _ssl.c \ -DUSE_SSL -I$(SSL)/include -I$(SSL)/include/openssl \ -L$(SSL)/lib -lssl -lcrypto $ ll /usr/lib/ssl total 4 lrwxrwxrwx 1 root ro

Re: argparse ConfigureAction problem

2012-03-26 Thread Jason Friedman
> ./plot_stuff2.py --plot stuff1 stuff2 > [...] > plot_stuff2.py: error: argument --plot/--with-plot/--enable-plot/--no-plot/-- > without-plot/--disable-plot: invalid boolean value: 'stuff1' > > Problem is --plot takes an optional argument, and so the positional arg is > assumed to be the arg to --

Re: Why does this hang sometimes?

2012-04-07 Thread Jason Friedman
> I am just playing around with threading and subprocess and found that > the following program will hang up and never terminate every now and > again. > > import threading > import subprocess > import time > > def targ(): >    p = subprocess.Popen(["/bin/sleep", "2"]) >    while p.poll() is None:

Re: Sharing Data in Python

2012-05-17 Thread Jason Friedman
> I have some Pickled data, which is stored on disk, and it is about 100 MB in > size. > > When my python program is executed, the picked data is loaded using the > cPickle module, and all that works fine. > > If I execute the python multiple times using python main.py for example, each > python

Re: python3 raw strings and \u escapes

2012-06-15 Thread Jason Friedman
This is a related question. I perform an octal dump on a file: $ od -cx file 000 h e l l o w o r l d \n 65686c6c206f6f776c720a64 I want to output the names of those characters: $ python3 Python 3.2.3 (default, May 19 2012, 17:01:30) [GCC

Re: python3 raw strings and \u escapes

2012-06-15 Thread Jason Friedman
>> This is a related question. >> >> I perform an octal dump on a file: >> $ od -cx file >> 000   h   e   l   l   o       w   o   r   l   d  \n >>            6568    6c6c    206f    6f77    6c72    0a64 >> >> I want to output the names of those characters: >> $ python3 >> Python 3.2.3 (default,

Embedding Python in a shell script

2011-06-16 Thread Jason Friedman
$ cat test.sh #!/bin/bash for i in 1 2 3 4; do python -c " for j in range($i): print j " done $ sh test.sh 0 0 1 0 1 2 0 1 2 3 The code behaves as I expect and want, but the de-denting of the Python call is unattractive, especially unattractive the longer the Python call becomes. I'd prefe

Re: Embedding Python in a shell script

2011-06-17 Thread Jason Friedman
Thank you, everyone, for your suggestions. I'll try them all and decide which I like best. -- http://mail.python.org/mailman/listinfo/python-list

Re: Help with regular expression in python

2011-08-19 Thread Jason Friedman
> Hi Josh, > thanks for the reply. I am no expert so please bear with me: > I thought that the {32} was supposed to match the previous expression 32 > times? > > So how can i have all matches accessible to me? $ python Python 2.6.5 (r265:79063, Apr 16 2010, 13:57:41) [GCC 4.4.3] on linux2 Type "he

Re: Fibonacci series recursion error

2011-04-29 Thread Jason Friedman
> import os > def fib(n): >        if n == 1: >          return(n) >        else: >          return (fib(n-1)+fib(n-2)) > > list=fib(20) > print(list) > > The above function return the > return (fib(n-1)+fib(n-2)) > > > RuntimeError: maximum recursion depth exceeded in comparison > [36355 refs] > >

Re: Sending Email using examples From Tutorials

2018-01-27 Thread Jason Friedman
> > import smtplib > server = smtplib.SMTP('localhost') > server.sendmail('gg77gal...@yahoo.com', > """To: gg.gal...@gmail.com > From: gg77gal...@yahoo.com > > Beware the Ides of March. > """) > server.quit() > > when running this I get the following message. Please help: > > Traceback (most recent

Re: Any users of statistics.mode() here?

2018-02-20 Thread Jason Friedman
> statistics.mode() currently raises an exception if there is more than one > mode. > I am an infrequent user of this package and this function. My two cents: * Leave the current behavior as-is. * Continue to throw an exception for no data. * Add an argument, named perhaps mutli=False, that if se

Re: APPLICATION NOT RUNNING.

2018-03-02 Thread Jason Friedman
> > I try to run an application with the latest version of python that is > python 3.6.4 (32-bit) ., instead of running the application it only shows > feel free to mail python-list@python.org if you continue to encounter > issues,Please help me out thanks. > Hello, you might have more success if

Re: Python 3.11.0 installation and Tkinter does not work

2022-11-23 Thread Jason Friedman
> > I want learn python for 4 weeks and have problems, installing Tkinter. If > I installed 3.11.0 for my windows 8.1 from python.org and type > > >>> import _tkinter > > Traceback (most recent call last): > >File "", line 1, in > > ImportError: DLL load failed while importing _tkinter

Best practice for database connection

2023-05-31 Thread Jason Friedman
I'm trying to reconcile two best practices which seem to conflict. 1) Use a _with_ clause when connecting to a database so the connection is closed in case of premature exit. class_name = 'oracle.jdbc.OracleDriver' url = f"jdbc:oracle:thin:@//{host_name}:{port_number}/{database_name}" with jdbc.c

Re: For example: Question, moving a folder (T061RR7N1) containing a Specific file (ReadCMI), to folder: C:\\...\DUT0

2021-01-27 Thread Jason Friedman
> > > for path, dir, files in os.walk(myDestinationFolder): > # for path, dir, files in os.walk(destfolder): > print('The path is %s: ', path) > print(files) > os.chdir(mySourceFolder) > if not os.path.isfile(myDestinationFolder + file): > # if not os.path.isfile(destfolder + f

Re: What's the meaning the "backlog" in the socket.listen(backlog) is?

2021-02-16 Thread Jason Friedman
> > I set listen(2) and expect to see "error" when more clients than "the > maximum number of queued connections" trying to connect the server. But, no > error!! Even 4 clients can run normally without problem. > > Am I misunderstanding the meaning of this argument? > https://docs.python.org/3/lib

Determine what the calling program is

2021-04-18 Thread Jason Friedman
I should state at the start that I have a solution to my problem. I am writing to see if there is a better solution. I have a program that runs via crontab every five minutes. It polls a Box.com folder for files and, if any are found, it copies them locally and performs a computation on them that

Re: Set git config credential.helper cache and timeout via python

2021-12-11 Thread Jason Friedman
> Hey All, > > I have a set of bash and python scripts that all interact with a remote > git repository. > This does not exactly answer your question, but whenever I have wanted to interact with (popular) software via Python I have checked to see if someone has already written that code for me. h

Re: Set git config credential.helper cache and timeout via python

2021-12-11 Thread Jason Friedman
> > > Hey All, > > I have a set of bash and python scripts that all interact with a remote > git repository. > > > https://gitpython.readthedocs.io/en/stable/reference.html?highlight=cache#git.index.fun.read_cache > https://pypi.org/project/git-credential-helpers/ > > But neither means appears to h

Stompy

2016-09-25 Thread Jason Friedman
My goal is to send messages to an AMQ server using Python 3.3. I found Stompy and performed 2to3-3.3 before building. I am open to non-Stompy solutions. My code: from stompy.stomp import Stomp my_stomp = Stomp(AMQ_HOST, AMQ_PORT) my_stomp.connect(AMQ_USERNAME, AMQ_PASSWORD) My error: Traceback

Re: Stompy

2016-09-25 Thread Jason Friedman
> > My error: >> Traceback (most recent call last): >> File "temp.py", line 8, in >> my_stomp.connect(AMQ_USERNAME, AMQ_PASSWORD) >> File "/lclapps/oppen/thirdparty/stompy/stomp.py", line 48, in connect >> self.frame.connect(self.sock, username=username, password=password, >> clientid=

Re: Internet Data Handling » mailbox

2016-10-23 Thread Jason Friedman
> > for message in mailbox.mbox(sys.argv[1]): > if message.has_key("From") and message.has_key("To"): > addrs = message.get_all("From") > addrs.extend(message.get_all("To")) > for addr in addrs: > addrl = addr.lower() >

Re: passing a variable to cmd

2016-11-06 Thread Jason Friedman
> > import subprocess > import shlex > > domname = raw_input("Enter your domain name: "); > print "Your domain name is: ", domname > > print "\n" > > # cmd='dig @4.2.2.2 nbc.com ns +short' > cmd="dig @4.2.2.2 %s ns +short", % (domname) > proc=subprocess.Popen(shlex.split(cmd),stdout=subprocess.PIPE

Re: Options for stdin and stdout when using pdb debugger

2016-11-25 Thread Jason Friedman
> I would like to use pdb in an application where it isn't possible to use > sys.stdin for input. I've read in the documentation for pdb.Pdb that a file > object can be used instead of sys.stdin. Unfortunately, I'm not clear about > my options for the file object. > > I've looked at rpdb on PyPI

List comprehension

2016-12-30 Thread Jason Friedman
$ python Python 3.6.0 (default, Dec 26 2016, 18:23:08) [GCC 4.8.4] on linux Type "help", "copyright", "credits" or "license" for more information. >>> data = ( ... (1,2), ... (3,4), ... ) >>> [a for a in data] [(1, 2), (3, 4)] Now, this puzzles me: >>> [x,y for a in data] File "", line 1 [x

Re: List comprehension

2016-12-30 Thread Jason Friedman
> data = ( >> ... (1,2), >> ... (3,4), >> ... ) >> > [x,y for a in data] >> File "", line 1 >> [x,y for a in data] >>^ >> SyntaxError: invalid syntax >> >> I expected: >> [(1, 2), (3, 4)] > > > Why would you expect that? I would expect the global variables x and y, or > if

Re: Do not promote `None` as the first argument to `filter` in documentation.

2018-03-06 Thread Jason Friedman
On Tue, Mar 6, 2018 at 1:52 AM, Kirill Balunov wrote: > > I propose to delete all references in the `filter` documentation that the > first argument can be `None`, with possible depreciation of `None` as the > the first argument - FutureWarning in Python 3.8+ and deleting this option > in Python

Re: # of Months between two dates

2018-04-05 Thread Jason Friedman
> > > > I've written a function to return the months between date1 and date2 > but > > > I'd like to know if anyone is aware of anything in the standard library > > > to do the same? For bonus points, does anyone know if postgres can do > > > the same (we use a lot of date/time funcitons in postgr

Re: # of Months between two dates

2018-04-06 Thread Jason Friedman
> > >> > It's probably better to write the function yourself according to what > >> > makes sense in your use-case, and document its behaviour clearly. > >> > >> > > I suggest using the dateutil module ( > > https://pypi.python.org/pypi/python-dateutil) before writing your own. > > I'm not seeing a

Re: how to set timeout for os.popen

2018-04-15 Thread Jason Friedman
> > while 1: > runner = os.popen("tracert -d www.hello.com") > o=runner.read() > print(o) > runner.close() > runner = os.popen("tracert -d www.hello.com") > o=runner.read() > print(o) > runner.close() > runner = os.popen("tracert -d www.hello.com") > o=runner.read() > print(o) > runner.close() > >

defaultdict and datetime

2018-08-18 Thread Jason Friedman
$ python3 Python 3.6.1 (default, Apr 8 2017, 09:56:20) [GCC 5.4.0 20160609] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import collections, datetime >>> x = collections.defaultdict(int) >>> x['something'] 0 >>> x = collections.defaultdict(datetime.datetime)

Re: Bottle framework references

2018-08-21 Thread Jason Friedman
> > I am building up the microsite based on Bottle framework now. > Any references/books? I am unfamiliar with this framework yet. > > I have used it with success. The online documentation was sufficient for my needs, at least. -- https://mail.python.org/mailman/listinfo/python-list

Re: Bottle framework references

2018-08-24 Thread Jason Friedman
> > > > On 22 Aug 2018, at 8:38 am, Jason Friedman wrote: > > > >> > >> I am building up the microsite based on Bottle framework now. > >> Any references/books? I am unfamiliar with this framework yet. > >> > >> I have used it with

Re: Add header at top with email.message

2018-09-15 Thread Jason Friedman
> > the EmailMessage class of email.message provides the methods > add_header() and __setitem__() to add a header to a message. > add_header() effectively calls __setitem__(), which does > `self._headers.append(self.policy.header_store_parse(name, val))`. This > inserts the header at the bottom. >

Re: namedtuples anamoly

2018-10-18 Thread Jason Friedman
> > So now the real question is: What were you trying to accomplish with > the assignment? Tell us, and let's see if we can find a way to > accomplish yor goal without wrecking the internals of the Grade class. > > And depending on your answer to that question, the new Data Classes feature in 3.7

Re: i cant seem to figure out the error

2016-04-03 Thread Jason Friedman
> >- Create a method called `withdraw` that takes in cash withdrawal amount >and updates the balance accordingly. if amount is greater than balance >return `"invalid transaction"` > > def withdraw(self, amount): > self.amount=amount > if(amount > self.balance): > return

Re: i cant seem to figure out the error

2016-04-03 Thread Jason Friedman
> def deposit(self, amount): > self.amount=amount > self.balance += amount > return self.balance > > > def withdraw(self, amount): > self.amount=amount > if(amount > self.balance): > return ("Amount greater than available balance.") > else: > self.balance -= amou

Re: Python,ping,csv

2016-04-09 Thread Jason Friedman
> for ping in range(1,254): > address = "10.24.59." + str(ping) > res = subprocess.call(['ping', '-c', '3', address]) > if res == 0: > print ("ping to", address, "OK") > elif res == 2: > print ("no response from", address) > else: > print ("ping to", addr

Re: Python,ping,csv

2016-04-11 Thread Jason Friedman
> I added a line. > I would need to put the output into a csv file which contained the results > of the hosts up and down. > Can you help me? > > > import subprocess > from ipaddress import IPv4Network > for address in IPv4Network('10.24.59.0/24').hosts(): > a = str(address) > res =

Re: Python,ping,csv

2016-04-11 Thread Jason Friedman
> I added a line. > I would need to put the output into a csv file which contained the > results of the hosts up and down. > Can you help me? > > import subprocess > from ipaddress import IPv4Network > for address in IPv4Network('10.24.59.0/24').hosts(): > a = str(address) > res = sub

Re: Why online forums have bad behaviour (was: Steve D'Aprano, you're the "master". What's wrong with this concatenation statement?)

2016-05-12 Thread Jason Friedman
> TL;DR: because we're all human, and human behaviour needs either > immediate face-to-face feedback or social enforcement to correct > selfishness and abrasiveness. Where face-to-face feedback is lacking, > social enforcement needs to take more of the load. > > > Many people have a false sense of

Re: How can I debug silent failure - print no output

2016-05-27 Thread Jason Friedman
> > def GetArgs(): > '''parse XML from command line''' > parser = argparse.ArgumentParser() > > parser.add_argument("path", nargs="+") > parser.add_argument('-e', '--extension', default='', > help='File extension to filter by.') > args = parser.parse_args

Re: python parsing suggestion

2016-05-30 Thread Jason Friedman
> > Trying to extract the '1,1,114688:8192' pattern form the below output. > > pdb>stdout: > '3aae5d0-1: Parent Block for 1,1,19169280:8192 (block 1,1,114688:8192) > --\n3aae5d0-1: > magic 0xdeaff2fe mark_cookie > 0x\ngpal-3aae5d0-1: super.status > 3s

  1   2   3   >