Re: Love to get some feedback on my first python app!!!

2014-09-21 Thread Nicholas Cannon
On Saturday, September 20, 2014 9:17:27 PM UTC+8, Nicholas Cannon wrote:
> I have created my first python program and I have learnt a lot about python 
> from this group and wanted some feedback. I am still improving it and trying 
> to tackle some performance and GUI stuff so keep that in mind. I don't think 
> it is the best program but is a good product of 3 months of python.
> 
> 
> 
> link: https://github.com/nicodasiko/Article-Grab

I just updated the whole app to include a scroll bar, loading bar and I used 
multi threading to update the scroll bar whilst scraping the data from the web. 
I need to work on performance though but I have defiantly improved it now!
-- 
https://mail.python.org/mailman/listinfo/python-list


pgs4a fails to build

2014-09-21 Thread aws Al-Aisafa
Hi everyone. So I have this problem with building with pgs4a.
when I try to build I always end with this error:

/home/aws/Desktop/pgs4a-0.9.6/android-sdk/tools/ant/build.xml:483: SDK does not 
have any Build Tools installed.

could you please help me? Thank you in advance.
-- 
https://mail.python.org/mailman/listinfo/python-list


Error from hg.python.org

2014-09-21 Thread Mark Lawrence
I've noticed this a few times recently using the Sync command from 
TortoiseHg on Windows 8.1.


% hg pull --verbose --update --config ui.merge=internal:merge 
http://hg.python.org/cpython

HTTP Error: 500 (Internal Server Error)
[command returned code 255 Sun Sep 21 14:22:52 2014]

Is this related to an upgrade that has been done in the last few weeks 
or is that a complete red herring?


--
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


ssl.SSLError: [SSL: BAD_WRITE_RETRY] bad write retry (_ssl.c:1636)

2014-09-21 Thread Nikolaus Rath
Hello,

Can someone explain help me understand what this exception means?

[...]
  File 
"/usr/local/lib/python3.4/dist-packages/dugong-3.2-py3.4.egg/dugong/__init__.py",
 line 584, in _co_send
len_ = self._sock.send(buf)
  File "/usr/lib/python3.4/ssl.py", line 679, in send
v = self._sslobj.write(data)
ssl.SSLError: [SSL: BAD_WRITE_RETRY] bad write retry (_ssl.c:1636)

Presumably this is generated by OpenSSL, but how do I figure out what it
means? The best I found in the OpenSSL documentation is
https://www.openssl.org/docs/crypto/err.html, and Google only found
brought me to https://stackoverflow.com/questions/2997218.


Best,
-Nikolaus
-- 
GPG encrypted emails preferred. Key id: 0xD113FCAC3C4E599F
Fingerprint: ED31 791B 2C5C 1613 AF38 8B8A D113 FCAC 3C4E 599F

 »Time flies like an arrow, fruit flies like a Banana.«
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Error from hg.python.org

2014-09-21 Thread Terry Reedy

On 9/21/2014 9:28 AM, Mark Lawrence wrote:

I've noticed this a few times recently using the Sync command from
TortoiseHg on Windows 8.1.

% hg pull --verbose --update --config ui.merge=internal:merge
http://hg.python.org/cpython
HTTP Error: 500 (Internal Server Error)
[command returned code 255 Sun Sep 21 14:22:52 2014]

Is this related to an upgrade that has been done in the last few weeks
or is that a complete red herring?


You might ask on the core-mentorship list.

--
Terry Jan Reedy

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


Re: pgs4a fails to build

2014-09-21 Thread aws Al-Aisafa
Yes I've followed and installed everything
-- 
https://mail.python.org/mailman/listinfo/python-list


SOAPpy: Expected to find node type 'Element' with name 'CountriesFetchingRequest'; Found node type 'Element' with name 'FetchCountries'

2014-09-21 Thread vek . m1234
I'm messing with SOAP, trying to write a small library to handle stuff I buy 
from Aramex (shipper). I'm learning XML/SOAP and I'm familiar with RPC from C 
(Stevens) but no other relevant experience. If this is incredibly dumb just 
ignore it since I'll probably figure it out eventually.

I'm trying to get a list of countries by calling the CoutriesFetchingRequest 
method - this is documented here:
http://www.aramex.com/developers/aramex-apis/47442/Location-Services-API
http://www.aramex.com/content/uploads/109/232/46790/aramex-location-api-manual.pdf

It takes as its arguments a 'ClientInfo' data-structure and 'Code' which is a 
string.

There is also a 'FetchCountries' method with an 'input' and 'output' something.
However python was more clear, print server.show_methods():

Method Name: FetchCountries 
   In #0: parameters  ((u'http://ws.aramex.net/ShippingAPI/v1/', 
u'CountriesFetchingRequest'))


The trouble is I don't understand how to call 'CoutriesFetchingRequest' or pass 
it to FetchCountries. Could someone clarify?


The WSDL for Aramex has this:
http://www.aramex.com/content/uploads/109/232/46790/location-api-wsdl.zip

  http://ws.aramex.net/ShippingAPI/v1/Service_1_0/FetchCountries"; 
name="CountriesFetchingRequest" message="tns:CountriesFetchingRequest" />
  http://ws.aramex.net/ShippingAPI/v1/Service_1_0/FetchCountriesResponse";
 name="CountriesFetchingResponse" message="tns:CountriesFetchingResponse" />



  

  

My python code:
#!/usr/bin/python
import xml, fpconst, logging
from SOAPpy import WSDL
from suds.client import Client

logging.basicConfig(level=logging.INFO)
logging.getLogger('suds.client').setLevel(logging.DEBUG)

foo = { 'AccountCountryCode' : 'JO', 'AccountEntity' : 'AMM', 'AccountNumber' : 
'20016', 'AccountPin' : '331421', 'UserName' : 'testing...@aramex.com', 
'Password' : 'R123456789$r', 'Version' : 'v1.0', 'Source' : '', 'Transaction' : 
 { 'Reference1' : '001', 'Reference2' : '002', 'Reference3' : '003', 
'Reference4' : '004', 'Reference5' : '005' } }

wsdl_file = '/home/veek/location-api-wsdl/Location-API-WSDL.wsdl'

server = WSDL.Proxy(wsdl_file)
print server.methods.keys()
print dir(server)
print server.show_methods()
callInfo = server.methods['FetchCountries']
print type(callInfo)
print dir(callInfo)

for arg in callInfo.inparams:
print arg.name.ljust(15), arg.type
server.namespace = 'http://ws.aramex.net/ShippingAPI/v1/'
x = server.FetchCountries.CountriesFetchingRequest(foo)

The output i get is:
[u'FetchCountries', u'FetchCountry', u'ValidateAddress', u'FetchCities', 
u'FetchOffices']
['__doc__', '__getattr__', '__init__', '__module__', '__str__', 'methods', 
'show_methods', 'soapproxy', 'wsdl']
Method Name: FetchCountries 

   In #0: parameters  ((u'http://ws.aramex.net/ShippingAPI/v1/', 
u'CountriesFetchingRequest'))

   Out #0: parameters  ((u'http://ws.aramex.net/ShippingAPI/v1/', 
u'CountriesFetchingResponse'))



None

['__doc__', '__init__', '__module__', 'addInHeaderInfo', 'addInParameter', 
'addOutHeaderInfo', 'addOutParameter', 'documentation', 'encodingStyle', 
'getInHeaders', 'getInParameters', 'getOutHeaders', 'getOutParameters', 
'getReturnParameter', 'inheaders', 'inparams', 'location', 'methodName', 
'namespace', 'outheaders', 'outparams', 'retval', 'setReturnParameter', 
'soapAction', 'style', 'transport', 'use']
parameters  (u'http://ws.aramex.net/ShippingAPI/v1/', 
u'CountriesFetchingRequest')



SOAPpy.Types.faultType: http://ws.aramex.net/ShippingAPI/v1/'. Found node type 'Element' with name 
'FetchCountries.CountriesFetchingRequest' and namespace '': 

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


Re: program to generate data helpful in finding duplicate large files

2014-09-21 Thread bizcor
thanks for the responses.   i'm having quite a good time learning python.

On Thu, Sep 18, 2014 at 11:45 AM, Chris Kaynor 
wrote:
>
> Additionally, you may want to specify binary mode by using open(file_path,
> 'rb') to ensure platform-independence ('r' uses Universal newlines, which
> means on Windows, Python will convert "\r\n" to "\n" while reading the
> file). Additionally, some platforms will treat binary files differently.
>

would it be good to use 'rb' all the time?

On Thu, Sep 18, 2014 at 11:48 AM, Chris Angelico  wrote:

> On Fri, Sep 19, 2014 at 4:11 AM, David Alban  wrote:
> > exit( 0 )
>
> Unnecessary - if you omit this, you'll exit 0 implicitly at the end of
> the script.
>

aha.  i've been doing this for years even with perl, and apparently it's
not necessary in perl either.  i was influenced by shell.

this shell code:

* if [[ -n $report_mode ]] ; then*
*do_report*
* fi*

* exit 0*

is an example of why you want the last normally executed shell statement to
be "exit 0".  if you omit the exit statement it in this example, and
$report_mode is not set, your shell program will give a non-zero return
code and appear to have terminated with an error.  in shell the last
expression evaluated determines the return code to the os.

ok, i don't need to do this in python.

On Thu, Sep 18, 2014 at 1:23 PM, Peter Otten <__pete...@web.de> wrote:
>
> file_path may contain newlines, therefore you should probably use "\0" to
> separate the records.


i chose to stick with ascii nul as the default field separator, but i added
a --field-separator option in case someone wants human readable output.

style question:  if there is only one, possibly short statement in a block,
do folks usually move it up to the line starting the block?

  *if not S_ISREG( mode ) or S_ISLNK( mode ):*
*return*

vs.

*if not S_ISREG( mode ) or S_ISLNK( mode ): return*

or even:

   *with open( file_path, 'rb' ) as f: md5sum = md5_for_file( file_path )*



fyi, here are my changes:


*usage: dupscan [-h] [--start-directory START_DIRECTORY]*
*   [--field-separator FIELD_SEPARATOR]*

*scan files in a tree and print a line of information about each regular
file*

*optional arguments:*
*  -h, --helpshow this help message and exit*
*  --start-directory START_DIRECTORY, -d START_DIRECTORY*
*Specify the root of the filesystem tree to be*
*processed. The default is '.'*
*  --field-separator FIELD_SEPARATOR, -s FIELD_SEPARATOR*
*Specify the string to use as a field separator in*
*output. The default is the ascii nul character.*



*#!/usr/bin/python*

*import argparse*
*import hashlib*
*import os*

*from platform import node*
*from stat import S_ISREG, S_ISLNK*

*ASCII_NUL = chr(0)*

* # from:
http://stackoverflow.com/questions/1131220/get-md5-hash-of-big-files-in-python
*
* # except that i use hexdigest() rather than digest()*
*def md5_for_file( path, block_size=2**20 ):*
*  md5 = hashlib.md5()*
*  with open( path, 'rb' ) as f:*
*while True:*
*  data = f.read(block_size)*
*  if not data:*
*break*
*  md5.update(data)*
*  return md5.hexdigest()*

*def file_info( directory, basename, field_separator=ASCII_NUL ):*
*  file_path = os.path.join( directory, basename )*
*  st = os.lstat( file_path )*

*  mode = st.st_mode*
*  if not S_ISREG( mode ) or S_ISLNK( mode ): *
*return*

*  with open( file_path, 'rb' ) as f:*
*md5sum = md5_for_file( file_path )*

*  return field_separator.join( [ thishost, md5sum, str( st.st_dev ), str(
st.st_ino ), str( st.st_nlink ), str( st.st_size ), file_path ] )*

*if __name__ == "__main__":*
*  parser = argparse.ArgumentParser(description='scan files in a tree and
print a line of information about each regular file')*
*  parser.add_argument('--start-directory', '-d', default='.',
help='''Specify the root of the filesystem tree to be processed.  The
default is '.' ''')*
*  parser.add_argument('--field-separator', '-s', default=ASCII_NUL,
help='Specify the string to use as a field separator in output.  The
default is the ascii nul character.')*
*  args = parser.parse_args()*

*  start_directory = args.start_directory.rstrip('/')*
*  field_separator = args.field_separator*

*  thishost = node()*
*  if thishost == '':*
*thishost='[UNKNOWN]'*

*  for directory_path, directory_names, file_names in os.walk(
start_directory ):*
*for file_name in file_names:*
*  print file_info( directory_path, file_name, field_separator )*



-- 
Live in a world of your own, but always welcome visitors.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: ssl.SSLError: [SSL: BAD_WRITE_RETRY] bad write retry (_ssl.c:1636)

2014-09-21 Thread dieter
Nikolaus Rath  writes:

> Can someone explain help me understand what this exception means?
>
> [...]
>   File 
> "/usr/local/lib/python3.4/dist-packages/dugong-3.2-py3.4.egg/dugong/__init__.py",
>  line 584, in _co_send
> len_ = self._sock.send(buf)
>   File "/usr/lib/python3.4/ssl.py", line 679, in send
> v = self._sslobj.write(data)
> ssl.SSLError: [SSL: BAD_WRITE_RETRY] bad write retry (_ssl.c:1636)
>
> Presumably this is generated by OpenSSL, but how do I figure out what it
> means? The best I found in the OpenSSL documentation is
> https://www.openssl.org/docs/crypto/err.html, and Google only found
> brought me to https://stackoverflow.com/questions/2997218.

I would first look at the source: "_ssl.c" (source of the Python
module interfacing with OpenSSL) near line 1636.
Likely, this only reports a problem reported by "OpenSSL".
Next step would then be to look at the "OpenSSL" documentation or
source to find out what the error reported by "OpenSSL" means.

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


Re: SOAPpy: Expected to find node type 'Element' with name 'CountriesFetchingRequest'; Found node type 'Element' with name 'FetchCountries'

2014-09-21 Thread dieter
vek.m1...@gmail.com writes:

> I'm messing with SOAP, trying to write a small library to handle stuff I buy 
> from Aramex (shipper). I'm learning XML/SOAP and I'm familiar with RPC from C 
> (Stevens) but no other relevant experience. If this is incredibly dumb just 
> ignore it since I'll probably figure it out eventually.
> ...
> The trouble is I don't understand how to call 'CoutriesFetchingRequest' or 
> pass it to FetchCountries. Could someone clarify?

I have no experience with "SOAPpy", but with "suds" (another Python
SAOP client). A "suds" client exposes two attributes "factory"
and "service". You use the "factory" to create Python objects
for types defined by the WSDL; you then set  their attributes with standard
Python means (maybe involving other "factory" calls). Finally
you call the methods via the "service" attribute passing arguments
of the appropiate type in the normal Python way.

I suppose, it is similar with "SOAPpy". Looking at its documentation
and/or its examples may provide you with the necessary details.
Otherwise, you could also use "suds".

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