Advice needed for Python packaging - can't find required library during installation

2014-02-03 Thread thebiggestbangtheory
Hello all,

I am trying to package up a very simple python app. In my setup.py file I have 
a couple of lines that include the following:

from setuptools import setup

setup(
name='ban',
version='0.1',
packages=['ban',],
description='Python Distribution Utilities',
author='Ban',
author_email='[email protected]',
package_data={'ban': ['data/*.dat']},
long_description=open('README.txt').read(),
install_requires=['Google-Safe-Browsing-v2-Lookup'],
)


The error I see when running:
$> python setup.py install

***
running install
running bdist_egg
running egg_info
writing requirements to ban.egg-info/requires.txt
writing ban.egg-info/PKG-INFO
writing top-level names to ban.egg-info/top_level.txt
writing dependency_links to ban.egg-info/dependency_links.txt
reading manifest file 'ban.egg-info/SOURCES.txt'
writing manifest file 'ban.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_py
creating build
creating build/lib.linux-x86_64-2.6
creating build/lib.linux-x86_64-2.6/ban
copying ban/analyzer.py -> build/lib.linux-x86_64-2.6/ban
copying ban/__init__.py -> build/lib.linux-x86_64-2.6/ban
creating build/bdist.linux-x86_64
creating build/bdist.linux-x86_64/egg
creating build/bdist.linux-x86_64/egg/ban
copying build/lib.linux-x86_64-2.6/ban/analyzer.py -> 
build/bdist.linux-x86_64/egg/ban
copying build/lib.linux-x86_64-2.6/ban/__init__.py -> 
build/bdist.linux-x86_64/egg/ban
byte-compiling build/bdist.linux-x86_64/egg/ban/analyzer.py to analyzer.pyc
byte-compiling build/bdist.linux-x86_64/egg/ban/__init__.py to __init__.pyc
creating build/bdist.linux-x86_64/egg/EGG-INFO
copying ban.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO
copying ban.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying ban.egg-info/dependency_links.txt -> 
build/bdist.linux-x86_64/egg/EGG-INFO
copying ban.egg-info/requires.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying ban.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
zip_safe flag not set; analyzing archive contents...
creating dist
creating 'dist/ban-0.1-py2.6.egg' and adding 'build/bdist.linux-x86_64/egg' to 
it 
removing 'build/bdist.linux-x86_64/egg' (and everything under it)
Processing ban-0.1-py2.6.egg
removing '/usr/local/lib/python2.6/dist-packages/ban-0.1-py2.6.egg' (and 
everything under it)
creating /usr/local/lib/python2.6/dist-packages/ban-0.1-py2.6.egg
Extracting ban-0.1-py2.6.egg to /usr/local/lib/python2.6/dist-packages
ban 0.1 is already the active version in easy-install.pth

Installed /usr/local/lib/python2.6/dist-packages/ban-0.1-py2.6.egg
Processing dependencies for ban==0.1
Searching for Google-Safe-Browsing-v2-Lookup
Reading http://pypi.python.org/simple/Google-Safe-Browsing-v2-Lookup/
No local packages or download links found for Google-Safe-Browsing-v2-Lookup
error: Could not find suitable distribution for 
Requirement.parse('Google-Safe-Browsing-v2-Lookup')
**

Issue #1

Apparently the setup script cannot find the package - 
Google-Safe-Browsing-v2-Lookup . However, I can install this package via pip. 

What should I specify in the setup.py file instead of 
install_requires=['Google-Safe-Browsing-v2-Lookup'] so that the library is 
properly installed ?


Any advice is appreciated.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Advice needed for Python packaging - can't find required library during installation

2014-02-04 Thread thebiggestbangtheory
Thank you very much! :-)

On Monday, February 3, 2014 11:30:00 PM UTC-8, dieter wrote:
> [email protected] writes:
> 
> 
> 
> > I am trying to package up a very simple python app. In my setup.py file I 
> > have a couple of lines that include the following:
> 
> >
> 
> > from setuptools import setup
> 
> >
> 
> > setup(
> 
> > name='ban',
> 
> > version='0.1',
> 
> > packages=['ban',],
> 
> > description='Python Distribution Utilities',
> 
> > author='Ban',
> 
> > author_email='[email protected]',
> 
> > package_data={'ban': ['data/*.dat']},
> 
> > long_description=open('README.txt').read(),
> 
> > install_requires=['Google-Safe-Browsing-v2-Lookup'],
> 
> > )
> 
> > ...
> 
> > Processing dependencies for ban==0.1
> 
> > Searching for Google-Safe-Browsing-v2-Lookup
> 
> > Reading http://pypi.python.org/simple/Google-Safe-Browsing-v2-Lookup/
> 
> > No local packages or download links found for Google-Safe-Browsing-v2-Lookup
> 
> > error: Could not find suitable distribution for 
> > Requirement.parse('Google-Safe-Browsing-v2-Lookup')
> 
> > **
> 
> >
> 
> > Issue #1
> 
> >
> 
> > Apparently the setup script cannot find the package - 
> > Google-Safe-Browsing-v2-Lookup . However, I can install this package via 
> > pip. 
> 
> >
> 
> > What should I specify in the setup.py file instead of 
> > install_requires=['Google-Safe-Browsing-v2-Lookup'] so that the library is 
> > properly installed ?
> 
> 
> 
> I suppose that "setuptools" is confused by the "-" in the package
> 
> names together with these "-" being omitted in the uploaded file
> 
> (https://pypi.python.org/packages/source/G/Google-Safe-Browsing-v2-Lookup/Google%20Safe%20Browsing%20v2%20Lookup-0.1.0.tar.gz5";).
> 
> 
> 
> If this supposition is correct, then you would either need to
> 
> contact the "setuptools" author (to get "setuptools" handle this case)
> 
> or the "Google Safe Browsing" author to get a filename more
> 
> in line with the package name.

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


newbie: popen question

2009-05-27 Thread thebiggestbangtheory
hello everyone :-),
 I am a newbie to python. I am trying to run a
bash script from within a python program. I would greatly appreciate
any pointers/comments about how to get around the problem I am facing.

I want to run  bash script: code.sh from within a python program.
code.sh needs to be run like so from the command line
[code]
$ sudo code.sh arg1 arg2
[/code]

I read up on some documentation but am not very clear about how to use
popen. I want to relegate the shell to a background process, but it
needs to accept the sudo passwd too!

I have tried
[code]
p = subprocess.Popen(['/bin/bash', 'sudo '+mypath+'code.sh '+arg1+'
'+arg2],
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT)
[/code]
I tried some code from stackoverflow.com/questions/694000/why-doesnt-
subprocess-popen-always-return

nothing really happens when this executes, the PIPE option pshes it to
the background and I can't push in the sudo passwd. Can someone please
give me an idea of how to go about this.

To recap, I want to run a shell script, which needs to be started with
sudo, and then push it into the background.

Thanks,
-A
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: newbie: popen question

2009-05-28 Thread thebiggestbangtheory
On May 28, 5:31 am, Sebastian Wiesner  wrote:
> 
>
> > Your best bet is to make sudo not ask for a password.  :)  If you
> > don't have the rights, then you can use pexpect to do what you want to
> > do.  http://pexpect.sourceforge.net/pexpect.html
>
> > See the second example on that page.
>
> > child = pexpect.spawn('scp foo [email protected]:.')
> > child.expect ('Password:')
> > child.sendline (mypassword)
>
> The sudo password prompt is very configurable, so changing the configuration
> to allow execution without password input is really the best option.
>
> --
> Freedom is always the freedom of dissenters.
>                                       (Rosa Luxemburg)

Thanks guys for helping out! very good answers :-)

Before I saw your answers, I tried the following,

output = subprocess.Popen(["sudo","-b", "code.sh", "arg1"],
stdout=subprocess.PIPE).communicate()[0]

This seemed to push the shell execution process to the background and
because my python program was invoked initially with sudo, it seems I
did not need to enter a passwd again.

Any comments about this..any issues that you see will crop up?

Thanks a ton again.



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


problem with sockets and transferring binary files

2009-06-02 Thread thebiggestbangtheory
Dear all,
   I am a python newbie. I am now progressing to writing a
network app in python to learn more about it. I have a client and a
server in python. The client sends a msg to the server asking it to
tar a binary .dbxml file and then send it over to it. The steps are:
from the
1. Client sends msg to server
2. Server tars up binary file and Encrypts it using ezpycrypto
3. Server sends it to client
4. Client receives file and decrypts it and untars it

Surprisingly, the sha1 hash of the encrypted data before it is sent
from server is different  from the encrypted file data received by the
client. I post some code below to provide more info about what I am
doing.

[code]
#client after sending initial msg
#get server replywhich sends back the .dbxml file
myHost = '127.0.0.1'
myPort = 20001

s1 = socket(AF_INET, SOCK_STREAM)# create a TCP socket
s1.bind((myHost, myPort))# bind it to the server
port
s1.listen(1) # allow 1 simultaneous
  # pending connections

connection, address = s1.accept() # connection is a new socket
while 1:
  data = connection.recv(1000) # receive up to 1000
bytes
  if data:
info=decryptfile(data)

#we have recieved a compressed .tar.gz file
#write out info to a file
buf = open(currentpath+'received-container.tar.gz', 'w')
buf.write(info)
buf.close()

#testing code: must be removed
os.system('sudo sha1sum '+currentpath+'received-xml-
container.tar.gz')

#uncompress
os.system('sudo tar -xvzf '+currentpath+'received-xml-
container.tar.gz')

[/code]
[code]
#the server after receiving the msg from client
#dump the binary file
os.system('sudo cp '+'/'+path+'1.binary '+currentpath
+'1.binary')

#compress the file
os.system('sudo tar -cvzf '+currentpath+'1.bin.tar.gz
'+currentpath+'1.binary')

#encrypt the file specified in command line
cipher=encryptfile(secretkey, currentpath+'1.bin.tar.gz')

#send it over to sender
send_to_sender(cipher, senderaddress)

#testing code: needs to be removed
buf = open(currentpath+'cipher', 'w')
buf.write(cipher)
buf.close()
os.system('sudo sha1sum '+currentpath+'cipher')
[/code]
[code]
#function code
def send_to_sender(cipher, servername):
PORT = 20001
BUFF = 1000
clientSocket = socket(AF_INET, SOCK_STREAM)
HOST = servername
ADDR = (HOST, PORT)
clientSocket.connect(ADDR)
clientSocket.send(cipher)
clientSocket.close()
[/code]

What I see at the client side is

7105b60d3167f2424d9e2806c49cca86c00577ba  received-container.tar.gz

gzip: stdin: unexpected end of file
tar: Unexpected EOF in archive
tar: Unexpected EOF in archive
tar: Error is not recoverable: exiting now
da39a3ee5e6b4b0d3255bfef95601890afd80709  received-container.tar.gz

gzip: stdin: unexpected end of file
tar: Child returned status 1
tar: Error exit delayed from previous errors

It seems two file pieces are received! but why? The buffer size is big
enough to accept the whole thing in one go. The binary file is about
460K in size.

Any pointers, comments will be greatly appreciated :-).

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


Re: problem with sockets and transferring binary files

2009-06-02 Thread thebiggestbangtheory
On Jun 2, 10:29 pm, "Gabriel Genellina" 
wrote:
> En Wed, 03 Jun 2009 01:54:02 -0300,   
> escribió:
>
> >            I am a python newbie. I am now progressing to writing a
> > network app in python to learn more about it. [...]
> > Surprisingly, the sha1 hash of the encrypted data before it is sent
> > from server is different  from the encrypted file data received by the
> > client.
> >           data = connection.recv(1000) # receive up to 1000
> > bytes
>
> recv returns *up* *to* 1000 bytes: maybe only one byte.
> You'll have to keep recv'ing the pieces until you get an empty string  
> (when client closes the connection), or send the file size first and then  
> the actual data.
>
> >             buf = open(currentpath+'received-container.tar.gz', 'w')
> >             buf.write(info)
> >             buf.close()
>
> If you're on Linux it doesn't matter, but the 'w' above should be 'wb' for  
> a binary file.
>
> > def send_to_sender(cipher, servername):
> >     ...
> >     clientSocket.send(cipher)
>
> Similar to recv above: send() might not send the whole string at once (try  
> sendall instead).
>
> --
> Gabriel Genellina

Thanks! :-) very helpful
-- 
http://mail.python.org/mailman/listinfo/python-list