Respam levels.

2018-02-13 Thread C W Rose via Python-list

Having run a check for straightforward spam, I now find that there's a site
editing and reposting non-spam posts.  An example of the changed headers
follows:

Original post headers:
>
> From c...@seckford.org Sun Feb 11 23:23:22 2018
> Path: 
> eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
> Message-ID: <4sd3le-ct4@tanner.seckford.org>
> From: C W Rose 
> Newsgroups: comp.lang.python
> Subject: Spam levels.
> Date: Sat, 10 Feb 2018 14:57:40 +
> Lines: 49
> Organization: None
> Injection-Info: reader02.eternal-september.org; 
> posting-host="208e6410f66c7dd789dea67159b51bb7";
>   logging-data="6406"; mail-complaints-to="ab...@eternal-september.org";  
> posting-account="U2FsdGVkX18su+yG7dqCpnqChqoPIY0JNXRwgNWzvcs="
> User-Agent: tin/2.0.1-20111224 ("Achenvoir") (UNIX) (Linux/3.10.79-gentoo-1 
> (i686))
> Cancel-Lock: sha1:H7zOidR0ivbNjqiWUB6DSoMMYu8=
> Xref: tanner.seckford.org comp.lang.python:139461
> 

Repost headers:
>
> From C Sun Feb 11 23:22:54 2018
> Path: 
> eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!aioe.org!news.bbs.geek.nz!.POSTED.agency.bbs.geek.nz!not-for-mail
> Message-ID: <847574...@f38.n261.z1.binkp.net>
> From: C W Rose  (C W Rose)
> Newsgroups: comp.lang.python
> Subject: Spam levels.
> Date: Sat, 10 Feb 2018 14:57:40 +1200
> Organization: fsxNet Usenet Gateway | bbs.nz/#fsxNet
> Mime-Version: 1.0
> Content-Type: text/plain; charset=us-ascii
> Content-Transfer-Encoding: 7bit
> Injection-Info: news.bbs.geek.nz; 
> posting-host="M6YmRdZYyc42DJk0lNlt/X4dpP4dzvceBNabSmESN3E";
>   logging-data="24378"; mail-complaints-to="ab...@news.bbs.geek.nz"
> User-Agent: VSoup v1.2.9.47Beta [95/NT]
> X-MailConverter: SoupGate-Win32 v1.05
> X-Comment-To: All
> Xref: tanner.seckford.org comp.lang.python:139479

Looking at my current comp.lang.python news spool, 182 out of 683 messages
have been reposted by news.bbs.geek.nz; I haven't checked if they are all
duplicates.  The reformatting of the body of message is to date trivial,
just a reduction in line length.

This may be the result of a misconfigured spam filter, or an actual spam
attack; anyway, I've now filtered news.bbs.geek.nz from my feed.

Will

-- 
"When we look around us, this is what we find,
 The hope that springs eternal, springs right up your behind."
  -- Ian Dury

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


Regex on a Dictionary

2018-02-13 Thread Stanley Denman
I am trying to performance a regex on a "string" of text that python isinstance 
is telling me is a dictionary.  When I run the code I get the following error:

{'/Title': '1F:  Progress Notes  Src.:  MILANI, JOHN C Tmt. Dt.:  05/12/2014 - 
05/28/2014 (9 pages)', '/Page': IndirectObject(465, 0), '/Type': '/FitB'}

Traceback (most recent call last):
  File "C:\Users\stand\Desktop\PythonSublimeText.py", line 9, in 
x=MyRegex.findall(MyDict)
TypeError: expected string or bytes-like object

Here is the "string" of code I am working with:

{'/Title': '1F:  Progress Notes  Src.:  MILANI, JOHN C Tmt. Dt.:  05/12/2014 - 
05/28/2014 (9 pages)', '/Page': IndirectObject(465, 0), '/Type': '/FitB'}

I want to grab the name "MILANI, JOHN C" and the last date "-mm/dd/" as a 
pair such that if I have  X numbers of string like the above I will end out 
with N pairs of values (name and date)/  Here is my code:
 
import PyPDF2,re
pdfFileObj=open('x.pdf','rb')
pdfReader=PyPDF2.PdfFileReader(pdfFileObj)
Result=pdfReader.getOutlines()
MyDict=(Result[-1][0])
print(MyDict)
print(isinstance(MyDict,dict))
MyRegex=re.compile(r"MILANI,")
x=MyRegex.findall(MyDict)
print(x)

Thanks in advance for any help.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Regex on a Dictionary

2018-02-13 Thread Etienne Robillard

Hi Stanley,


Le 2018-02-13 à 08:11, Stanley Denman a écrit :

x=MyRegex.findall(MyDict)

How about:
x = [MyRegex.findall(item) for item in MyDict]

Etienne

--
Etienne Robillard
tkad...@yandex.com
https://www.isotopesoftware.ca/

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


Re: Regex on a Dictionary

2018-02-13 Thread Rhodri James

On 13/02/18 13:11, Stanley Denman wrote:

I am trying to performance a regex on a "string" of text that python isinstance 
is telling me is a dictionary.  When I run the code I get the following error:

{'/Title': '1F:  Progress Notes  Src.:  MILANI, JOHN C Tmt. Dt.:  05/12/2014 - 
05/28/2014 (9 pages)', '/Page': IndirectObject(465, 0), '/Type': '/FitB'}

Traceback (most recent call last):
   File "C:\Users\stand\Desktop\PythonSublimeText.py", line 9, in 
 x=MyRegex.findall(MyDict)
TypeError: expected string or bytes-like object

Here is the "string" of code I am working with:

{'/Title': '1F:  Progress Notes  Src.:  MILANI, JOHN C Tmt. Dt.:  05/12/2014 - 
05/28/2014 (9 pages)', '/Page': IndirectObject(465, 0), '/Type': '/FitB'}

I want to grab the name "MILANI, JOHN C" and the last date "-mm/dd/" as a 
pair such that if I have  X numbers of string like the above I will end out with N pairs of values 
(name and date)/  Here is my code:
  
import PyPDF2,re

pdfFileObj=open('x.pdf','rb')
pdfReader=PyPDF2.PdfFileReader(pdfFileObj)
Result=pdfReader.getOutlines()
MyDict=(Result[-1][0])
print(MyDict)
print(isinstance(MyDict,dict))
MyRegex=re.compile(r"MILANI,")
x=MyRegex.findall(MyDict)
print(x)


As the error message says, re.findall() expects a string.  A dictionary 
is in no sense a string, so passing it in whole like that won't work. 
If you know that the name will always show up in the title field, you 
can pass just the title:


  x = MyRegex.findall(MyDict['/Title'])

Otherwise you will have to loop through all the entries in the dictionary:

  for entry in MyDict.values():
x = MyRegex.findall(entry)
# ...and do something with x

I rather suspect you are going to find that the titles aren't in a very 
systematic format, though.


--
Rhodri James *-* Kynesim Ltd
--
https://mail.python.org/mailman/listinfo/python-list


Re: Regex on a Dictionary

2018-02-13 Thread alister via Python-list
On Tue, 13 Feb 2018 13:42:08 +, Rhodri James wrote:

> On 13/02/18 13:11, Stanley Denman wrote:
>> I am trying to performance a regex on a "string" of text that python
>> isinstance is telling me is a dictionary.  When I run the code I get
>> the following error:
>> 
>> {'/Title': '1F:  Progress Notes  Src.:  MILANI, JOHN C Tmt. Dt.: 
>> 05/12/2014 - 05/28/2014 (9 pages)', '/Page': IndirectObject(465, 0),
>> '/Type': '/FitB'}
>> 
>> Traceback (most recent call last):
>>File "C:\Users\stand\Desktop\PythonSublimeText.py", line 9, in
>>
>>  x=MyRegex.findall(MyDict)
>> TypeError: expected string or bytes-like object
>> 
>> Here is the "string" of code I am working with:
>> 
>> {'/Title': '1F:  Progress Notes  Src.:  MILANI, JOHN C Tmt. Dt.: 
>> 05/12/2014 - 05/28/2014 (9 pages)', '/Page': IndirectObject(465, 0),
>> '/Type': '/FitB'}
>> 
>> I want to grab the name "MILANI, JOHN C" and the last date
>> "-mm/dd/" as a pair such that if I have  X numbers of string like
>> the above I will end out with N pairs of values (name and date)/  Here
>> is my code:
>>   
>> import PyPDF2,re pdfFileObj=open('x.pdf','rb')
>> pdfReader=PyPDF2.PdfFileReader(pdfFileObj)
>> Result=pdfReader.getOutlines()
>> MyDict=(Result[-1][0])
>> print(MyDict)
>> print(isinstance(MyDict,dict))
>> MyRegex=re.compile(r"MILANI,")
>> x=MyRegex.findall(MyDict)
>> print(x)
> 
> As the error message says, re.findall() expects a string.  A dictionary
> is in no sense a string, so passing it in whole like that won't work.
> If you know that the name will always show up in the title field, you
> can pass just the title:
> 
>x = MyRegex.findall(MyDict['/Title'])
> 
> Otherwise you will have to loop through all the entries in the
> dictionary:
> 
>for entry in MyDict.values():
>  x = MyRegex.findall(entry) # ...and do something with x
> 
> I rather suspect you are going to find that the titles aren't in a very
> systematic format, though.

for what purpose are you trying to run this regex anyway?
it is almost certainly the wrong approach for your task



-- 
Larkinson's Law:
All laws are basically false.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Respam levels.

2018-02-13 Thread alister via Python-list
On Tue, 13 Feb 2018 12:49:26 +, C W Rose wrote:

> Having run a check for straightforward spam, I now find that there's a
> site editing and reposting non-spam posts.  An example of the changed
> headers follows:
> 
> Original post headers:
>>
>> From c...@seckford.org Sun Feb 11 23:23:22 2018 Path:
>> eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-
mail
>> Message-ID: <4sd3le-ct4@tanner.seckford.org>
>> From: C W Rose 
>> Newsgroups: comp.lang.python Subject: Spam levels.
>> Date: Sat, 10 Feb 2018 14:57:40 + Lines: 49 Organization: None
>> Injection-Info: reader02.eternal-september.org;
>> posting-host="208e6410f66c7dd789dea67159b51bb7";
>>  logging-data="6406"; mail-complaints-to="abuse@eternal-
september.org";
>>  posting-account="U2FsdGVkX18su+yG7dqCpnqChqoPIY0JNXRwgNWzvcs="
>> User-Agent: tin/2.0.1-20111224 ("Achenvoir") (UNIX)
>> (Linux/3.10.79-gentoo-1 (i686))
>> Cancel-Lock: sha1:H7zOidR0ivbNjqiWUB6DSoMMYu8=
>> Xref: tanner.seckford.org comp.lang.python:139461
>> 
>> 
> Repost headers:
>>
>> From C Sun Feb 11 23:22:54 2018 Path:
>> eternal-september.org!reader02.eternal-september.org!feeder.eternal-
september.org!aioe.org!news.bbs.geek.nz!.POSTED.agency.bbs.geek.nz!not-
for-mail
>> Message-ID: <847574...@f38.n261.z1.binkp.net>
>> From: C W Rose  (C W Rose)
>> Newsgroups: comp.lang.python Subject: Spam levels.
>> Date: Sat, 10 Feb 2018 14:57:40 +1200 Organization: fsxNet Usenet
>> Gateway | bbs.nz/#fsxNet Mime-Version: 1.0 Content-Type: text/plain;
>> charset=us-ascii Content-Transfer-Encoding: 7bit Injection-Info:
>> news.bbs.geek.nz;
>> posting-host="M6YmRdZYyc42DJk0lNlt/X4dpP4dzvceBNabSmESN3E";
>>  logging-data="24378"; mail-complaints-to="ab...@news.bbs.geek.nz"
>> User-Agent: VSoup v1.2.9.47Beta [95/NT]
>> X-MailConverter: SoupGate-Win32 v1.05 X-Comment-To: All Xref:
>> tanner.seckford.org comp.lang.python:139479
> 
> Looking at my current comp.lang.python news spool, 182 out of 683
> messages have been reposted by news.bbs.geek.nz; I haven't checked if
> they are all duplicates.  The reformatting of the body of message is to
> date trivial, just a reduction in line length.
> 
> This may be the result of a misconfigured spam filter, or an actual spam
> attack; anyway, I've now filtered news.bbs.geek.nz from my feed.
> 
> Will

many thanks for the effort 
/dev/null on my laptop is now almost full with this junk :-)



-- 
Let's do it.
-- Gary Gilmore, to his firing squad
-- 
https://mail.python.org/mailman/listinfo/python-list


RE: Can't Uninstall !

2018-02-13 Thread Pedro Crescencio
Hello Michael, 

Here my answers

1. Why do you want to uninstall it? What are you trying to accomplish by
uninstalling it?
-> I installed Python to test a software. Now I do not need python any more.

2. What operating system are you using?
-> Windows 10 Familly 64b

3. How did you try to uninstall it?
Using Windows standard uninstall procedure 
https://www.windowscentral.com/how-to-uninstall-apps-windows-10

4. What messages did you get when you tried to uninstall it?
The message says : "Uninstalled". But I still have the icon over the App
list. 

5. How did you install two different 3.x versions?
I tried to reinstall to do a proper uninstall. I tried with the latest
version that might fix some bugs. 




-Message d'origine-
De : Python-list [mailto:python-list-bounces+pedronac=gmail@python.org]
De la part de Michael F. Stemper
Envoyé : mardi 13 février 2018 01:07
À : python-list@python.org
Objet : Re: Can't Uninstall !

On 2018-02-12 11:54, Pedro Crescencio wrote:

> Hello,

> I tried to uninstall Python, but it is not possible.
> 
> Even when message say it is uninstalled :

> The software is still on applications menu:

> How do I do to uninstall it ?
> 
> I have the same problem with booth python versions (3.6.4 and 3.7.0b1) 
> and the Sourcetree of Atlassian.

A few questions:

1. Why do you want to uninstall it? What are you trying to
accomplish by uninstalling it?
2. What operating system are you using?
3. How did you try to uninstall it?
4. What messages did you get when you tried to uninstall it?
5. How did you install two different 3.x versions?

--
Michael F. Stemper
Indians scattered on dawn's highway bleeding; Ghosts crowd the young child's
fragile eggshell mind.
--
https://mail.python.org/mailman/listinfo/python-list

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


Re: Regex on a Dictionary

2018-02-13 Thread Mark Lawrence

On 13/02/18 13:11, Stanley Denman wrote:

I am trying to performance a regex on a "string" of text that python isinstance 
is telling me is a dictionary.  When I run the code I get the following error:

{'/Title': '1F:  Progress Notes  Src.:  MILANI, JOHN C Tmt. Dt.:  05/12/2014 - 
05/28/2014 (9 pages)', '/Page': IndirectObject(465, 0), '/Type': '/FitB'}

Traceback (most recent call last):
   File "C:\Users\stand\Desktop\PythonSublimeText.py", line 9, in 
 x=MyRegex.findall(MyDict)
TypeError: expected string or bytes-like object

Here is the "string" of code I am working with:


Please call it a dictionary as in the subject line, quite clearly it is 
not a string in any way, shape or form.




{'/Title': '1F:  Progress Notes  Src.:  MILANI, JOHN C Tmt. Dt.:  05/12/2014 - 
05/28/2014 (9 pages)', '/Page': IndirectObject(465, 0), '/Type': '/FitB'}

I want to grab the name "MILANI, JOHN C" and the last date "-mm/dd/" as a 
pair such that if I have  X numbers of string like the above I will end out with N pairs of values 
(name and date)/  Here is my code:
  
import PyPDF2,re

pdfFileObj=open('x.pdf','rb')
pdfReader=PyPDF2.PdfFileReader(pdfFileObj)
Result=pdfReader.getOutlines()
MyDict=(Result[-1][0])
print(MyDict)
print(isinstance(MyDict,dict))
MyRegex=re.compile(r"MILANI,")
x=MyRegex.findall(MyDict)
print(x)

Thanks in advance for any help.



Was the string methods solution that I gave a week or so ago so bad that 
you still think that you need a regex to solve this?


--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

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


Re: Respam levels.

2018-02-13 Thread Mark Lawrence

On 13/02/18 12:49, C W Rose via Python-list wrote:


Having run a check for straightforward spam, I now find that there's a site
editing and reposting non-spam posts.  An example of the changed headers
follows:

Original post headers:


 From c...@seckford.org Sun Feb 11 23:23:22 2018
Path: eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
Message-ID: <4sd3le-ct4@tanner.seckford.org>
From: C W Rose 
Newsgroups: comp.lang.python
Subject: Spam levels.
Date: Sat, 10 Feb 2018 14:57:40 +
Lines: 49
Organization: None
Injection-Info: reader02.eternal-september.org; 
posting-host="208e6410f66c7dd789dea67159b51bb7";
logging-data="6406"; mail-complaints-to="ab...@eternal-september.org";  
posting-account="U2FsdGVkX18su+yG7dqCpnqChqoPIY0JNXRwgNWzvcs="
User-Agent: tin/2.0.1-20111224 ("Achenvoir") (UNIX) (Linux/3.10.79-gentoo-1 
(i686))
Cancel-Lock: sha1:H7zOidR0ivbNjqiWUB6DSoMMYu8=
Xref: tanner.seckford.org comp.lang.python:139461



Repost headers:


 From C Sun Feb 11 23:22:54 2018
Path: 
eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!aioe.org!news.bbs.geek.nz!.POSTED.agency.bbs.geek.nz!not-for-mail
Message-ID: <847574...@f38.n261.z1.binkp.net>
From: C W Rose  (C W Rose)
Newsgroups: comp.lang.python
Subject: Spam levels.
Date: Sat, 10 Feb 2018 14:57:40 +1200
Organization: fsxNet Usenet Gateway | bbs.nz/#fsxNet
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Injection-Info: news.bbs.geek.nz; 
posting-host="M6YmRdZYyc42DJk0lNlt/X4dpP4dzvceBNabSmESN3E";
logging-data="24378"; mail-complaints-to="ab...@news.bbs.geek.nz"
User-Agent: VSoup v1.2.9.47Beta [95/NT]
X-MailConverter: SoupGate-Win32 v1.05
X-Comment-To: All
Xref: tanner.seckford.org comp.lang.python:139479


Looking at my current comp.lang.python news spool, 182 out of 683 messages
have been reposted by news.bbs.geek.nz; I haven't checked if they are all
duplicates.  The reformatting of the body of message is to date trivial,
just a reduction in line length.

This may be the result of a misconfigured spam filter, or an actual spam
attack; anyway, I've now filtered news.bbs.geek.nz from my feed.

Will



IIRC the same source for the "nospam" stuff of some months ago which I 
believe was purely accidental.


--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

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


Re: This newsgroup (comp.lang.python) may soon be blocked by Google Gro

2018-02-13 Thread Michael F. Stemper

On 2018-02-10 16:40, Chris Angelico wrote:

On Sun, Feb 11, 2018 at 8:52 AM, Chris Green  wrote:

Michael F. Stemper  wrote:

On 2018-02-09 13:37, Chris Green wrote:



  Use ssh (is that available at worK?) to connect from work to home


Your ISP provides that capability? I'm surprised. I'm with Charter and
the only external IP address is for the cable modem (I think).
"icanhazip" shows the same one, no matter which computer I use.


You use the same external IP address, just use the right port number
(which you set up your router to allow in).


Exactly. The easiest way is to set up port forwarding in your cable
modem. Any device worth using should have at least SOME measure of
port forwarding. Of course, if your ISP offers an IPv6 netblock, it's
easy.



Ah, the light dawns over Marblehead! When I set up my router, I saw
the "port forwarding" page, but had no idea what it was for. Thanks for
the explanation.

I will now cease off-topic posting.

--
Michael F. Stemper
This post contains greater than 95% post-consumer bytes by weight.
--
https://mail.python.org/mailman/listinfo/python-list


Defer, ensure library is loaded

2018-02-13 Thread Jason
I have a variety of scripts that import some large libraries, and rather than 
create a million little scripts with specific imports, I'd like to so something 
like

psycopg2 = ensure_imported (psycopg2)

This way, regardless of invocation I can know psycopg2 is loaded, if it hasn't 
already been loaded. If I just do a normal import 95% of the time I'll be 
waiting time with a meaningless import.


Can I do that somehow?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Defer, ensure library is loaded

2018-02-13 Thread Chris Angelico
On Wed, Feb 14, 2018 at 3:02 AM, Jason  wrote:
> I have a variety of scripts that import some large libraries, and rather than 
> create a million little scripts with specific imports, I'd like to so 
> something like
>
> psycopg2 = ensure_imported (psycopg2)
>
> This way, regardless of invocation I can know psycopg2 is loaded, if it 
> hasn't already been loaded. If I just do a normal import 95% of the time I'll 
> be waiting time with a meaningless import.
>
>
> Can I do that somehow?

Yep! It's written like this:

import psycopg2

If it's already been imported, Python will go fetch it straight from
the cache, so it's fast.

(The cache is in "sys.modules", if you're curious. "import sys" to
have a look at it.)

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Regex on a Dictionary

2018-02-13 Thread Steven D'Aprano
On Tue, 13 Feb 2018 05:11:20 -0800, Stanley Denman wrote:

> I am trying to performance a regex on a "string" of text that python
> isinstance is telling me is a dictionary.

Please believe Python when it tells you that something is a dictionary. 
Trust me, the interpreter knows. It doesn't matter how much you want 
something to be a string, if it is not a string, it isn't a string.



-- 
Steve

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


Re: Regex on a Dictionary

2018-02-13 Thread Steven D'Aprano
On Tue, 13 Feb 2018 13:53:04 +, Mark Lawrence wrote:

> Was the string methods solution that I gave a week or so ago so bad that
> you still think that you need a regex to solve this?

Sometimes regexes are needed, but often Jamie Zawinski is right:

Some people, when confronted with a problem, think "I know, 
I'll use regular expressions." Now they have two problems.


Using the nuclear-powered bulldozer of regular expressions to crack the 
peanut of a simple fixed-string matching problem is rarely a good idea.



-- 
Steve

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


Re: Packaging uwsgi flask app for non-programmers?

2018-02-13 Thread Israel Brewster
> 
> On Feb 6, 2018, at 12:12 PM, Israel Brewster  wrote:
> 
> I have been working on writing an Alexa skill which, as part of it, requires 
> a local web server on the end users machine - the Alexa skill sends commands 
> to this server, which runs them on the local machine. I wrote this local 
> server in Flask, and run it using uwsgi, using a command like: "uwsgi 
> serverconfig.ini".
> 
> The problem is that in order for this to work, the end user must:
> 
> 1) Install python 3.6 (or thereabouts)
> 2) Install a number of python modules, and
> 3) run a command line (from the appropriate directory)
> 
> Not terribly difficult, but when I think of my target audience (Alexa users), 
> I could easily see even these steps being "too complicated". I was looking at 
> pyinstaller to create a simple double-click application, but it appears that 
> pyinstaller needs a python script as the "base" for the application, whereas 
> my "base" is uwsgi. Also, I do need to leave a config file accessible for the 
> end user to be able to edit. Is there a way to use pyinstaller in this 
> scenario, or perhaps some other option that might work better to package 
> things up?

So at the moment, since there have been no suggestions for packaging, I'm 
getting by with a bash script that:

a) Makes sure python 3 is installed, prompting the user to install it if not
b) Makes sure pip and virtualenv are installed, and installs them if needed
c) Sets up a virtualenv in the distribution directory
d) Installs all needed modules in the virtualenv - this step requires that dev 
tools are installed, a separate install.
e) modifies the configuration files to match the user and directory, and 
f) Installs a launchd script to run the uwsgi application

This actually seems to work fairly well, and by giving the script a .command 
extension, which automatically gets associated with terminal under OS X, the 
end user can simply double-click setup.command without having to go into 
terminal themselves. The main stumbling block then is the install of python3 - 
the user still has to manually download and install it in addition to my code, 
which I'd prefer to avoid - having to install my code separate from the Alexa 
skill is already an annoyance. As such, I'm considering three possible 
solutions:

1) Make some sort of installer package that includes the python3 installer
2) Somehow automate the download and install of Python3, or
3) re-write my code to be python 2 compatible (since python 2 is included with 
the OS)

If anyone has any suggestions on how I could accomplish 1 or 2, I'd appreciate 
it. Thanks!

---
Israel Brewster
Systems Analyst II
Ravn Alaska
5245 Airport Industrial Rd
Fairbanks, AK 99709
(907) 450-7293
---

> 
> ---
> Israel Brewster
> Systems Analyst II
> Ravn Alaska
> 5245 Airport Industrial Rd
> Fairbanks, AK 99709
> (907) 450-7293
> ---
> 
> 
> 
> 
> -- 
> https://mail.python.org/mailman/listinfo/python-list

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


Re: Can't Uninstall !

2018-02-13 Thread Jerry Hill
On Tue, Feb 13, 2018 at 10:30 AM, Pedro Crescencio 
wrote:

3. How did you try to uninstall it?
> Using Windows standard uninstall procedure
> https://www.windowscentral.com/how-to-uninstall-apps-windows-10
>

​That page describes two different ways of uninstalling programs (from the
start screen, or from the Apps & Features control panel).  I don't know if
it matters, but it might help someone to know which one you used.​


> 4. What messages did you get when you tried to uninstall it?
> The message says : "Uninstalled". But I still have the icon over the App
> list.
>

​You say you have "the" icon.​

​What icon is that? A normal python install should have a bunch of
different stuff on the start menu -- on the Windows 7 installation ​I have
in front of me, I have a "Python 3.6" folder, with four different links
nested inside - "IDLE (Python 3.6 32-bit)", "Python 3.6 (32-bit)", "Python
3.6 Manuals (32-bit)", and "Python 3.6 Module Docs (32-bit)".  What do you
have?

​When you installed python, do you remember if you installed it for "All
Users" or "Just Me"?​

-- 
Jerry
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Regex on a Dictionary

2018-02-13 Thread Stanley Denman
On Tuesday, February 13, 2018 at 9:41:14 AM UTC-6, Mark Lawrence wrote:
> On 13/02/18 13:11, Stanley Denman wrote:
> > I am trying to performance a regex on a "string" of text that python 
> > isinstance is telling me is a dictionary.  When I run the code I get the 
> > following error:
> > 
> > {'/Title': '1F:  Progress Notes  Src.:  MILANI, JOHN C Tmt. Dt.:  
> > 05/12/2014 - 05/28/2014 (9 pages)', '/Page': IndirectObject(465, 0), 
> > '/Type': '/FitB'}
> > 
> > Traceback (most recent call last):
> >File "C:\Users\stand\Desktop\PythonSublimeText.py", line 9, in 
> >  x=MyRegex.findall(MyDict)
> > TypeError: expected string or bytes-like object
> > 
> > Here is the "string" of code I am working with:
> 
> Please call it a dictionary as in the subject line, quite clearly it is 
> not a string in any way, shape or form.
> 
> > 
> > {'/Title': '1F:  Progress Notes  Src.:  MILANI, JOHN C Tmt. Dt.:  
> > 05/12/2014 - 05/28/2014 (9 pages)', '/Page': IndirectObject(465, 0), 
> > '/Type': '/FitB'}
> > 
> > I want to grab the name "MILANI, JOHN C" and the last date "-mm/dd/" as 
> > a pair such that if I have  X numbers of string like the above I will end 
> > out with N pairs of values (name and date)/  Here is my code:
> >   
> > import PyPDF2,re
> > pdfFileObj=open('x.pdf','rb')
> > pdfReader=PyPDF2.PdfFileReader(pdfFileObj)
> > Result=pdfReader.getOutlines()
> > MyDict=(Result[-1][0])
> > print(MyDict)
> > print(isinstance(MyDict,dict))
> > MyRegex=re.compile(r"MILANI,")
> > x=MyRegex.findall(MyDict)
> > print(x)
> > 
> > Thanks in advance for any help.
> > 
> 
> Was the string methods solution that I gave a week or so ago so bad that 
> you still think that you need a regex to solve this?
> 
> -- 
> My fellow Pythonistas, ask not what our language can do for you, ask
> what you can do for our language.
> 
> Mark Lawrence

My Apology Mark.  You took the time to give me the basis of a non-regex 
solution and I had not taken the time to fully review your answer.Did not 
understand it at first blush, but I think now I do.
-- 
https://mail.python.org/mailman/listinfo/python-list


RE: Can't Uninstall !

2018-02-13 Thread Pedro Crescencio
RESOLVED

To answer Jerry, I found solution.

Point 3.
First try: uninstall using Windows 10 interface to uninstall 
Like this 
https://malwaretips.com/blogs/wp-content/uploads/2015/07/Uninstall-Application-from-Windows-10.jpg
Second try: right click over the program bouton on Start Menu
1st option of this link 
https://www.windowscentral.com/how-to-uninstall-apps-windows-10
It send to "Windows 7" like interface menu : 
http://www.uninstalltips.net/wp-content/uploads/2014/04/uninstall-program.png

The second works!
Can not explain why, but it does.
It's good enough. 

Thanks




-Message d'origine-
De : Python-list [mailto:python-list-bounces+pedronac=gmail@python.org] De 
la part de Jerry Hill
Envoyé : mardi 13 février 2018 19:01
À : python-list (General) 
Objet : Re: Can't Uninstall !

On Tue, Feb 13, 2018 at 10:30 AM, Pedro Crescencio 
wrote:

3. How did you try to uninstall it?
> Using Windows standard uninstall procedure
> https://www.windowscentral.com/how-to-uninstall-apps-windows-10
>

​That page describes two different ways of uninstalling programs (from the 
start screen, or from the Apps & Features control panel).  I don't know if it 
matters, but it might help someone to know which one you used.​


> 4. What messages did you get when you tried to uninstall it?
> The message says : "Uninstalled". But I still have the icon over the 
> App list.
>

​You say you have "the" icon.​

​What icon is that? A normal python install should have a bunch of different 
stuff on the start menu -- on the Windows 7 installation ​I have in front of 
me, I have a "Python 3.6" folder, with four different links nested inside - 
"IDLE (Python 3.6 32-bit)", "Python 3.6 (32-bit)", "Python
3.6 Manuals (32-bit)", and "Python 3.6 Module Docs (32-bit)".  What do you have?

​When you installed python, do you remember if you installed it for "All Users" 
or "Just Me"?​

--
Jerry
--
https://mail.python.org/mailman/listinfo/python-list

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


Re: Regex on a Dictionary

2018-02-13 Thread Mark Lawrence

On 13/02/18 18:08, Stanley Denman wrote:

On Tuesday, February 13, 2018 at 9:41:14 AM UTC-6, Mark Lawrence wrote:

On 13/02/18 13:11, Stanley Denman wrote:

I am trying to performance a regex on a "string" of text that python isinstance 
is telling me is a dictionary.  When I run the code I get the following error:

{'/Title': '1F:  Progress Notes  Src.:  MILANI, JOHN C Tmt. Dt.:  05/12/2014 - 
05/28/2014 (9 pages)', '/Page': IndirectObject(465, 0), '/Type': '/FitB'}

Traceback (most recent call last):
File "C:\Users\stand\Desktop\PythonSublimeText.py", line 9, in 
  x=MyRegex.findall(MyDict)
TypeError: expected string or bytes-like object

Here is the "string" of code I am working with:


Please call it a dictionary as in the subject line, quite clearly it is
not a string in any way, shape or form.



{'/Title': '1F:  Progress Notes  Src.:  MILANI, JOHN C Tmt. Dt.:  05/12/2014 - 
05/28/2014 (9 pages)', '/Page': IndirectObject(465, 0), '/Type': '/FitB'}

I want to grab the name "MILANI, JOHN C" and the last date "-mm/dd/" as a 
pair such that if I have  X numbers of string like the above I will end out with N pairs of values 
(name and date)/  Here is my code:
   
import PyPDF2,re

pdfFileObj=open('x.pdf','rb')
pdfReader=PyPDF2.PdfFileReader(pdfFileObj)
Result=pdfReader.getOutlines()
MyDict=(Result[-1][0])
print(MyDict)
print(isinstance(MyDict,dict))
MyRegex=re.compile(r"MILANI,")
x=MyRegex.findall(MyDict)
print(x)

Thanks in advance for any help.



Was the string methods solution that I gave a week or so ago so bad that
you still think that you need a regex to solve this?

--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence


My Apology Mark.  You took the time to give me the basis of a non-regex 
solution and I had not taken the time to fully review your answer.Did not 
understand it at first blush, but I think now I do.



Accepted :)

IIRC you might need a small tweak or two but certainly the foundations 
were there.


--
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence

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


Re: Packaging uwsgi flask app for non-programmers?

2018-02-13 Thread Dan Stromberg
On Tue, Feb 13, 2018 at 9:28 AM, Israel Brewster  wrote:
> As such, I'm considering three possible solutions:
>
> 1) Make some sort of installer package that includes the python3 installer
> 2) Somehow automate the download and install of Python3, or
> 3) re-write my code to be python 2 compatible (since python 2 is included 
> with the OS)
>
> If anyone has any suggestions on how I could accomplish 1 or 2, I'd 
> appreciate it. Thanks!

Would using homebrew help?

http://docs.python-guide.org/en/latest/starting/install3/osx/

BTW, you might use curl  | bash to get the ball rolling.

I wouldn't recommend moving from 3.x to 2.x, unless perhaps you use a
common subset.
-- 
https://mail.python.org/mailman/listinfo/python-list


Suggestions on programming in Python an email simple client

2018-02-13 Thread Maroso Marco
Hi,

what i'm trying to do is develop my own email client, but a simple one.

I just want it to connect to a specific email account and read the subject line 
of messages coming from a certain email address.

I then want it to be able to execute the command i wrote on the subject.

It would be nice if i could specify two parameters on the subject line

first : password;
second : command;

The first parameter is the password and the second is the command to be 
executed in the local pc where this program is running.

The program will have to show only email coming from a specific account
and if the mail is unread then it should read the subject line and find 
parameters.
The first parameter must match my hardcoded password, and the second parameter 
must be executed on the local pc (example ... c:\windows\notepad.exe)

It must check for new emails at a given timing (example ...every 30 seconds )
 (the timing can be hardcoded or specified in a separate file)

This is it.

Any suggestions?

I have started doing this (but i never programmed in python before):


import imaplib
import os
import email
import email.header

plusmail = "emailaddresstobechec...@gmail.com"
googlepass = "mypassword"
owner = "validsen...@gmail.com"

M = imaplib.IMAP4_SSL('imap.gmail.com')
M.login(plusmail, googlepass)
M.select()

status, response = M.search(None, '(UNSEEN)')
unread_msg_nums = response[0].split()

# Print the count of all unread messages
print (len(unread_msg_nums))

# Print all unread messages from a certain sender of interest
status, response = M.search(None, '(UNSEEN)', '(FROM "%s")' % (owner))
unread_msg_nums = response[0].split()
da = []
for e_id in unread_msg_nums:
_, response = imap.fetch(e_id, '(BODY.PEEK[HEADER.FIELDS (From Subject)] 
RFC822.SIZE)')
da.append(response[0][1])
# print (da)

# Mark them as seen
for e_id in unread_msg_nums:
imap.store(e_id, '+FLAGS', '\Seen')



typ, data = M.search(None, 'From',(owner))
for num in data[0].split():
typ, data = M.fetch(num, '(RFC822)')
print ('Message %s\n%s\n' % (num, data[0][1]))
M.close()
M.logout()

I know there are duplicates but i need to figure out how to build this 
correctly 


Thanks in advance for any help given.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Suggestions on programming in Python an email simple client

2018-02-13 Thread Chris Angelico
On Wed, Feb 14, 2018 at 7:05 AM, Maroso Marco  wrote:
> Hi,
>
> what i'm trying to do is develop my own email client, but a simple one.
>
> I just want it to connect to a specific email account and read the subject 
> line of messages coming from a certain email address.
>
> I then want it to be able to execute the command i wrote on the subject.

Be aware that "from" addresses can easily be forged. I suggest
whitelisting a set of valid commands and executing only those. If you
want a REAL way to manage your home system remotely, I would recommend
SSH instead.

> It would be nice if i could specify two parameters on the subject line
>
> first : password;
> second : command;
>
> The first parameter is the password and the second is the command to be 
> executed in the local pc where this program is running.

That's an improvement, but since the password is being transmitted in
clear text, it won't prevent attacks. It does mean you won't try to
execute the subject lines of random spam, though, so accidents will be
reduced (or eliminated).

> The program will have to show only email coming from a specific account
> and if the mail is unread then it should read the subject line and find 
> parameters.
> The first parameter must match my hardcoded password, and the second 
> parameter must be executed on the local pc (example ... 
> c:\windows\notepad.exe)
>
> It must check for new emails at a given timing (example ...every 30 seconds )
>  (the timing can be hardcoded or specified in a separate file)
>
> This is it.
>
> Any suggestions?

Seems perfectly possible.

> I have started doing this (but i never programmed in python before):
>
>
> import imaplib
> import os
> import email
> import email.header
>
> plusmail = "emailaddresstobechec...@gmail.com"
> googlepass = "mypassword"
> owner = "validsen...@gmail.com"
>
> M = imaplib.IMAP4_SSL('imap.gmail.com')
> M.login(plusmail, googlepass)
> M.select()
>
> status, response = M.search(None, '(UNSEEN)')
> unread_msg_nums = response[0].split()
>
> # Print the count of all unread messages
> print (len(unread_msg_nums))
>
> # Print all unread messages from a certain sender of interest
> status, response = M.search(None, '(UNSEEN)', '(FROM "%s")' % (owner))
> unread_msg_nums = response[0].split()
> da = []
> for e_id in unread_msg_nums:
> _, response = imap.fetch(e_id, '(BODY.PEEK[HEADER.FIELDS (From Subject)] 
> RFC822.SIZE)')
> da.append(response[0][1])
> # print (da)
>
> # Mark them as seen
> for e_id in unread_msg_nums:
> imap.store(e_id, '+FLAGS', '\Seen')
>
>
>
> typ, data = M.search(None, 'From',(owner))
> for num in data[0].split():
> typ, data = M.fetch(num, '(RFC822)')
> print ('Message %s\n%s\n' % (num, data[0][1]))
> M.close()
> M.logout()
>
> I know there are duplicates but i need to figure out how to build this 
> correctly

Seems like a reasonable start. So what's the code doing wrong, or
failing to do? Is it failing with an exception? Is it running
successfully, but not doing something you want it to do?

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Respam levels.

2018-02-13 Thread Gregory Ewing

Mark Lawrence wrote:
IIRC the same source for the "nospam" stuff of some months ago which I 
believe was purely accidental.


I have told the site admin about this, hopefully he will be able
to put a stop to it again.

--
Greg
--
https://mail.python.org/mailman/listinfo/python-list


Re: Suggestions on programming in Python an email simple client

2018-02-13 Thread Maroso Marco
Il giorno martedì 13 febbraio 2018 21:18:37 UTC+1, Chris Angelico ha scritto:
> On Wed, Feb 14, 2018 at 7:05 AM, Maroso Marco  wrote:
> > Hi,
> >
> > what i'm trying to do is develop my own email client, but a simple one.
> >
> > I just want it to connect to a specific email account and read the subject 
> > line of messages coming from a certain email address.
> >
> > I then want it to be able to execute the command i wrote on the subject.
> 
> Be aware that "from" addresses can easily be forged. I suggest
> whitelisting a set of valid commands and executing only those. If you
> want a REAL way to manage your home system remotely, I would recommend
> SSH instead.
> 
> > It would be nice if i could specify two parameters on the subject line
> >
> > first : password;
> > second : command;
> >
> > The first parameter is the password and the second is the command to be 
> > executed in the local pc where this program is running.
> 
> That's an improvement, but since the password is being transmitted in
> clear text, it won't prevent attacks. It does mean you won't try to
> execute the subject lines of random spam, though, so accidents will be
> reduced (or eliminated).
> 
> > The program will have to show only email coming from a specific account
> > and if the mail is unread then it should read the subject line and find 
> > parameters.
> > The first parameter must match my hardcoded password, and the second 
> > parameter must be executed on the local pc (example ... 
> > c:\windows\notepad.exe)
> >
> > It must check for new emails at a given timing (example ...every 30 seconds 
> > )
> >  (the timing can be hardcoded or specified in a separate file)
> >
> > This is it.
> >
> > Any suggestions?
> 
> Seems perfectly possible.
> 
> > I have started doing this (but i never programmed in python before):
> >
> >
> > import imaplib
> > import os
> > import email
> > import email.header
> >
> > plusmail = "emailaddresstobechec...@gmail.com"
> > googlepass = "mypassword"
> > owner = "validsen...@gmail.com"
> >
> > M = imaplib.IMAP4_SSL('imap.gmail.com')
> > M.login(plusmail, googlepass)
> > M.select()
> >
> > status, response = M.search(None, '(UNSEEN)')
> > unread_msg_nums = response[0].split()
> >
> > # Print the count of all unread messages
> > print (len(unread_msg_nums))
> >
> > # Print all unread messages from a certain sender of interest
> > status, response = M.search(None, '(UNSEEN)', '(FROM "%s")' % (owner))
> > unread_msg_nums = response[0].split()
> > da = []
> > for e_id in unread_msg_nums:
> > _, response = imap.fetch(e_id, '(BODY.PEEK[HEADER.FIELDS (From 
> > Subject)] RFC822.SIZE)')
> > da.append(response[0][1])
> > # print (da)
> >
> > # Mark them as seen
> > for e_id in unread_msg_nums:
> > imap.store(e_id, '+FLAGS', '\Seen')
> >
> >
> >
> > typ, data = M.search(None, 'From',(owner))
> > for num in data[0].split():
> > typ, data = M.fetch(num, '(RFC822)')
> > print ('Message %s\n%s\n' % (num, data[0][1]))
> > M.close()
> > M.logout()
> >
> > I know there are duplicates but i need to figure out how to build this 
> > correctly
> 
> Seems like a reasonable start. So what's the code doing wrong, or
> failing to do? Is it failing with an exception? Is it running
> successfully, but not doing something you want it to do?
> 
> ChrisA

Hi Chris and thanks for replying.

I came up with the following code (thanks for the security suggestions-i'm just 
testing) :

My code actually works fine allthough i have a couple of problems :

1 - once parced the messages and executed the command in the subject line, it 
keeps looping even if i told to only execute on unread messages
2 - it loops continuosly instead of waiting the correct wait time
3 - i had to add a delete statement so that the program stops looping at least 
on processing the commands.

Can you help me sort out the issue? Maybe it's an indent problem!


Here is the code : 

import imaplib
import os
import email
import email.header
import time

def mailcontroller():

# Set user, pass and allowed mail for giving commands
plusmail = "emailaddresstobechec...@gmail.com"
googlepass = "thesecretpassword"
captain = "theallowedemailaddr...@gmail.com"

# Set vars for IMAP access
M = imaplib.IMAP4_SSL('imap.gmail.com')
M.login(plusmail, googlepass)
M.select()

# Set search on UNSEEN messages
status, response = M.search(None, '(UNSEEN)')
unread_msg_nums = response[0].split()


# Mark as read
for e_id in unread_msg_nums:
M.store(e_id, '+FLAGS', '\Seen')

# cycle messages sent from autorized email address
typ, data = M.search(None, 'From',(captain))
for num in data[0].split():
typ, data = M.fetch(num, '(RFC822)')
msg = email.message_from_string(data[0][1])
decode = email.header.decode_header(msg['Subject'])[0]
subject = unicode(decode[0])
comando = subject

if googlepass in subject:
print 'Message %s: %s' % (num, subje

Re: Packaging uwsgi flask app for non-programmers?

2018-02-13 Thread Israel Brewster
> On Feb 13, 2018, at 10:02 AM, Dan Stromberg  wrote:
> 
> On Tue, Feb 13, 2018 at 9:28 AM, Israel Brewster  
> wrote:
>> As such, I'm considering three possible solutions:
>> 
>> 1) Make some sort of installer package that includes the python3 installer
>> 2) Somehow automate the download and install of Python3, or
>> 3) re-write my code to be python 2 compatible (since python 2 is included 
>> with the OS)
>> 
>> If anyone has any suggestions on how I could accomplish 1 or 2, I'd 
>> appreciate it. Thanks!
> 
> Would using homebrew help?
> 
> http://docs.python-guide.org/en/latest/starting/install3/osx/ 
> 

That's a thought. I could offer the user the option of either a) automatically 
installing homebrew and then installing python3 via homebrew, or b) manually 
downloading and running the python3 installer.

> 
> BTW, you might use curl  | bash to get the ball rolling.

On that note, is there a fixed url that will always get the latest python3 
installer? Of course, I might not want to do that, for example after 3.7 or 4.0 
(I know, not for a while) is released, just in case something breaks with a 
newer release.

> 
> I wouldn't recommend moving from 3.x to 2.x, unless perhaps you use a
> common subset.

Yeah, that idea kinda left a sour taste in my mouth, but I figured I'd throw it 
out there as it would solve the python install issue.

---
Israel Brewster
Systems Analyst II
Ravn Alaska
5245 Airport Industrial Rd
Fairbanks, AK 99709
(907) 450-7293
---
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Suggestions on programming in Python an email simple client

2018-02-13 Thread MRAB

On 2018-02-13 22:54, Maroso Marco wrote:

Il giorno martedì 13 febbraio 2018 21:18:37 UTC+1, Chris Angelico ha scritto:

On Wed, Feb 14, 2018 at 7:05 AM, Maroso Marco  wrote:
> Hi,
>
> what i'm trying to do is develop my own email client, but a simple one.
>
> I just want it to connect to a specific email account and read the subject 
line of messages coming from a certain email address.
>
> I then want it to be able to execute the command i wrote on the subject.

Be aware that "from" addresses can easily be forged. I suggest
whitelisting a set of valid commands and executing only those. If you
want a REAL way to manage your home system remotely, I would recommend
SSH instead.

> It would be nice if i could specify two parameters on the subject line
>
> first : password;
> second : command;
>
> The first parameter is the password and the second is the command to be 
executed in the local pc where this program is running.

That's an improvement, but since the password is being transmitted in
clear text, it won't prevent attacks. It does mean you won't try to
execute the subject lines of random spam, though, so accidents will be
reduced (or eliminated).

> The program will have to show only email coming from a specific account
> and if the mail is unread then it should read the subject line and find 
parameters.
> The first parameter must match my hardcoded password, and the second 
parameter must be executed on the local pc (example ... c:\windows\notepad.exe)
>
> It must check for new emails at a given timing (example ...every 30 seconds )
>  (the timing can be hardcoded or specified in a separate file)
>
> This is it.
>
> Any suggestions?

Seems perfectly possible.

> I have started doing this (but i never programmed in python before):
>
>
> import imaplib
> import os
> import email
> import email.header
>
> plusmail = "emailaddresstobechec...@gmail.com"
> googlepass = "mypassword"
> owner = "validsen...@gmail.com"
>
> M = imaplib.IMAP4_SSL('imap.gmail.com')
> M.login(plusmail, googlepass)
> M.select()
>
> status, response = M.search(None, '(UNSEEN)')
> unread_msg_nums = response[0].split()
>
> # Print the count of all unread messages
> print (len(unread_msg_nums))
>
> # Print all unread messages from a certain sender of interest
> status, response = M.search(None, '(UNSEEN)', '(FROM "%s")' % (owner))
> unread_msg_nums = response[0].split()
> da = []
> for e_id in unread_msg_nums:
> _, response = imap.fetch(e_id, '(BODY.PEEK[HEADER.FIELDS (From Subject)] 
RFC822.SIZE)')
> da.append(response[0][1])
> # print (da)
>
> # Mark them as seen
> for e_id in unread_msg_nums:
> imap.store(e_id, '+FLAGS', '\Seen')
>
>
>
> typ, data = M.search(None, 'From',(owner))
> for num in data[0].split():
> typ, data = M.fetch(num, '(RFC822)')
> print ('Message %s\n%s\n' % (num, data[0][1]))
> M.close()
> M.logout()
>
> I know there are duplicates but i need to figure out how to build this 
correctly

Seems like a reasonable start. So what's the code doing wrong, or
failing to do? Is it failing with an exception? Is it running
successfully, but not doing something you want it to do?

ChrisA


Hi Chris and thanks for replying.

I came up with the following code (thanks for the security suggestions-i'm just 
testing) :

My code actually works fine allthough i have a couple of problems :

1 - once parced the messages and executed the command in the subject line, it 
keeps looping even if i told to only execute on unread messages
2 - it loops continuosly instead of waiting the correct wait time
3 - i had to add a delete statement so that the program stops looping at least 
on processing the commands.

Can you help me sort out the issue? Maybe it's an indent problem!


Here is the code :

import imaplib
import os
import email
import email.header
import time

def mailcontroller():
 
 # Set user, pass and allowed mail for giving commands

 plusmail = "emailaddresstobechec...@gmail.com"
 googlepass = "thesecretpassword"
 captain = "theallowedemailaddr...@gmail.com"

 # Set vars for IMAP access
 M = imaplib.IMAP4_SSL('imap.gmail.com')
 M.login(plusmail, googlepass)
 M.select()

 # Set search on UNSEEN messages
 status, response = M.search(None, '(UNSEEN)')
 unread_msg_nums = response[0].split()


 # Mark as read
 for e_id in unread_msg_nums:
 M.store(e_id, '+FLAGS', '\Seen')


Here you iterate through all of the messages:


 # cycle messages sent from autorized email address
 typ, data = M.search(None, 'From',(captain))
 for num in data[0].split():
 typ, data = M.fetch(num, '(RFC822)')
 msg = email.message_from_string(data[0][1])
 decode = email.header.decode_header(msg['Subject'])[0]
 subject = unicode(decode[0])
 comando = subject

These lines are indented the same as the 'for' loop above, so they'll 
executed only the last message. If there are no messages, 'subject' 
won't be defined.



 if go

Django-hotsauce 1.0 commercial edition looking for beta testers!

2018-02-13 Thread Etienne Robillard

Hello everyone,

Django-hotsauce 1.0 commercial edition (LTS) is now available for 
preorder :)


Checkout: https://www.livestore.ca/product/django-hotsauce/

I'm also looking for expert Django and Python programmers to test and 
review the design and API of Django-hotsauce 1.0 commercial edition in 
order to develop a low-cost, high-performance, Django alternative 
microframework to develop scalable web apps in Python and WSGI. 
Furthermore, i will always be happy to support a free version of 
Django-hotsauce in order to drive the development and research of 
Python/Django web programming. :)


Final note, the Paypal payment gateway is experimental. I might one day 
decide to switch to monero or flashcoin... I'm not really sure it's a 
good idea yet.


What do you think?

Etienne


--
Etienne Robillard
tkad...@yandex.com
https://www.isotopesoftware.ca/

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


Re: Defer, ensure library is loaded

2018-02-13 Thread Steven D'Aprano
On Wed, 14 Feb 2018 03:08:07 +1100, Chris Angelico wrote:

[...]
> import psycopg2
> 
> If it's already been imported, Python will go fetch it straight from the
> cache, so it's fast.

Since Jason is talking about "a variety of scripts", it is quite possible 
that the sys.modules cache will not save him. Consider a scenario of a 
dozen scripts, each importing psycopg2. Since each script runs in its own 
interpreter process, sys.modules is cleared from one run to the next.

For scripts run by hand, this rarely matters. (After all, the time to run 
the script is often less than the time it takes to type in the command to 
run and hit Enter.) But for scripts called by other scripts, this can 
sometimes cause a significant slowdown.

(My understanding is that this is one of the reasons for the Apache 
module "mod_python", to ensure a single Apache process runs a single, 
long-running Python interpreter for any Python scripts, rather than 
starting and stopping a new interpreter like ordinary CGI scripts would 
do.)

I must admit though, I don't really understand Jason's problem or whether 
your answer is even relevant.



-- 
Steve

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


Re: Defer, ensure library is loaded

2018-02-13 Thread Steven D'Aprano
On Tue, 13 Feb 2018 08:02:38 -0800, Jason wrote:

> I have a variety of scripts that import some large libraries, and rather
> than create a million little scripts with specific imports, I'd like to
> so something like
> 
> psycopg2 = ensure_imported (psycopg2)
> 
> This way, regardless of invocation I can know psycopg2 is loaded, if it
> hasn't already been loaded. If I just do a normal import 95% of the time
> I'll be waiting time with a meaningless import.
> 
> 
> Can I do that somehow?

Jason, I'm afraid I don't understand your question. I don't understand 
what "ensure_imported" is supposed to do, or how it is different from a 
regular import, or where you are supposed to put it.

If you have a "million scripts" that look like this:

# count down from script 100 to 1...
import psycopg2
...

# script 99
import psycopg2
...

# script 98
import psycopg2
...


etc, how is that different from a million scripts that look like this?

# count down from script 100 to 1...
psycopg2 = ensure_imported(psycopg2)
...


Aside from the ensure_imported version being about double as much typing.

Nor do I understand what you mean by having to spend 95% of your time 
waiting for a meaningless import. If the import is "meaningless", that 
could only possibly mean that you aren't using the imported module. So 
the solution to that is to simply *not* import it. You shouldn't start 
off every module by importing a bazillion modules that you don't use. 
Import only what you actually use.

If you explain your problem a little better, we can possibly help you 
solve it.

Oh, one last thing... you cannot write something like this:

foomodule = ensure_imported(foomodule)

because the interpreter has to evaluate the value of the name "foomodule" 
on the right hand side of the assignment, and since it hasn't been 
imported yet, you will get a NameError. You have to write:

foomodule = ensure_imported("foomodule")  # note the quotation marks

to have it work.



-- 
Steve

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


Re: Django-hotsauce 1.0 commercial edition looking for beta testers!

2018-02-13 Thread Ned Batchelder

On 2/13/18 6:41 PM, Etienne Robillard wrote:

Hello everyone,

Django-hotsauce 1.0 commercial edition (LTS) is now available for 
preorder :)


Checkout: https://www.livestore.ca/product/django-hotsauce/

I'm also looking for expert Django and Python programmers to test and 
review the design and API of Django-hotsauce 1.0 commercial edition in 
order to develop a low-cost, high-performance, Django alternative 
microframework to develop scalable web apps in Python and WSGI. 
Furthermore, i will always be happy to support a free version of 
Django-hotsauce in order to drive the development and research of 
Python/Django web programming. :)


Final note, the Paypal payment gateway is experimental. I might one 
day decide to switch to monero or flashcoin... I'm not really sure 
it's a good idea yet.


There are a number of things that are confusing about this.  You should 
state clearly what django-hotsauce is. You say "Django alternative 
microframework."  Usually people use "Django" and "microframework" as 
opposites, not something you can combine together.


You say there will be a free version.  Does it already exist? Link to it.

Finally, you seem to be asking experts to volunteer their time to help 
you design and test software that you will then sell.  This seems 
unrealistic at best, and exploitive or unfair at worst.


--Ned.
--
https://mail.python.org/mailman/listinfo/python-list