How to access Apples iCal-Server via Python?

2015-05-24 Thread Norah Jones
Hi, 

I'm trying to access Apples iCal-Server on a Mac OS X Snow Leopard Server via 
Python. The server is up and running and working with it via the 
iCal-Application is just fine. Now I need to access this server via Python to 
use it as backend for resource planning.

So how can I read the events within a time range from a user's calendar using 
python?

Thanks,
Norah Jones


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


HTTP over Asynchronous AF_UNIX Socket in python

2015-01-26 Thread Norah Jones
Hi, 

The problem description:

There are set of processes running on my system say `process_set_1`. Build a 
process agent which runs an `asynchronous` socket listening to incoming 
requests from process_set_1. Each process sends an `id`. The agent stores these 
ids in a dictionary and sends response that ur id has been accepted. Now agent 
process receives some data from another process (which is some sort of sister 
process for the agent). This data contains id along with a command which is to 
be sent by the agent to the process_set_1 through HTTP client over `AF_UNIX` 
socket, since each process in process_set_1 has a HTTP listening CLI. The 
process agent sends an HTTP request by recognizing id stored in dictionary to 
the process_set_1. A service running in the process_set_1 routes this HTTP 
command to the respective process.

Now my problem is the HTTP request which to be sent must go through AF_UNIX 
socket. I got this solution.

class UnixStreamHTTPConnection(httplib.HTTPConnection):

def __init__(self, path, host='localhost/rg_cli',port=None, strict=None,
 timeout=None):
httplib.HTTPConnection.__init__(self, host, port=port, 
strict=strict,
timeout=timeout)
self.path=path

def connect(self):
self.sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
self.sock.connect(self.path)

But this cannot work since normal socket will not work and thus i thought of 
`asyncore` module in python. To use asyncore module again i will have to 
subclass asyncore.dispatcher. This class also contains connect() method.

Another problem is I don't know how asyncore module works and thus not able to 
find a way to mix the work of 1) listening forever, accept the connection, 
store id and the sock_fd. 
2) accept data from the process' agent sister process, retrieve the sock_fd by 
matching the id in the dictionary and send it through the AF_UNIX socket.

Please help since i have already spent 2 days digging it out. Sorry if could 
explain my problem very well.

Thanks,
Norah Jones


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


How does apache runs a application when a request comes in?

2014-05-06 Thread Norah Jones
Hi, 

I have a python web application running on apache2 deployed with `mod_wsgi`. 
The application has a thread continuously running. This thread is a ZeroMQ 
thread and listening to a port in loop. The application is not maintaining 
session. Now if I open the browser and sends a request to the apache server the 
data is accepted for the first time. Now when second time I send the request It 
shows Internal server error. When I checked the error log file for traceback,  
It shows the ZMQError:- The address already in use. 

Does apache reloads the application on each request sent from the  browser 
since so that the ZeroMQ thread is being created everytime and being assigned 
the port but since the port has already been assigned it shows error

Thanks,
Norah Jones


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


What is Application Context and Request Context in Flask and WerkZeug.

2014-04-07 Thread Norah Jones
Hi, 

I am developing a web application using flask, Werkzeug and jinja2. I am very 
much confused with these terms and wanted to know the meaning of the terms and 
how they are interrelated to the CGI environment variables. What is global 
variable g and how it is related to the application context and request context.

Also since I don't have much knowledge of developing web apps( I am doing it 
for first time) any another language also so there is another request if 
someone could give a reference or make me understand that how the requests are 
handled, i mean what happens when a request arrives to the web application.
Also if i am not using any openID providers for logging in the user into my 
website, how can i make the password secure. Should i use any framework for 
that?

Thanks,
Norah Jones


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


How to change scrollbar color in pygtk ?

2013-08-21 Thread Norah Jones
Hi, 

I Tried the below code, the color is not reflected, Am i missing something?

#add description box beside test cases
testCaseDescWindow = gtk.ScrolledWindow()
testCaseDescWindow.set_policy(gtk.POLICY_AUTOMATIC, 
gtk.POLICY_AUTOMATIC)

testCaseDescWindow.get_vscrollbar().modify_fg(gtk.STATE_NORMAL,gtk.gdk.color_parse('#40515F'))

testCaseDescWindow.get_hscrollbar().modify_fg(gtk.STATE_NORMAL,gtk.gdk.color_parse('#40515F'))


Thanks,
Norah Jones


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


Splitting a list into even size chunks in python?

2013-03-27 Thread Norah Jones
Hi, 

I have a list of arbitrary length, and I need to split it up into equal size 
chunks. There are some obvious ways to do this, like keeping a counter and two 
lists, and when the second list fills up, add it to the first list and empty 
the second list for the next round of data, but this is potentially extremely 
expensive.

I was wondering if anyone had a good solution to this for lists of any length 

This should work:

l = range(1, 1000)
print chunks(l, 10) - [ [ 1..10 ], [ 11..20 ], .., [ 991..999 ] ]

I was looking for something useful in itertools but I couldn't find anything 
obviously useful. 

Appretiate your help.


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


Multiple rows from MySQL query saved in an array structure

2013-03-20 Thread Norah Jones
I  have this Python code:


self.lock_tables(read, ['nets_permissions as n', 'devices_permissions as 
d'])
usrs = self.db.get(SELECT n.user_id FROM nets_permissions as n \
left join devices_permissions as d \
on n.user_id = d.user_id \
where d.user_id is null \
and n.network_id=%s and n.perm3, netid)
self.unlock_tables()

for usr in usrs:
self.lock_tables(write, ['devices_permissions'])
self.db.execute(INSERT devices_permissions SET \
 user_id=%s, network_id=%s, device_id=%s, perm=%s,\
 usr, netid, sensid, perm)
self.unlock_tables();

I first do a query to retrieve some user_id from two tables. I want save this 
user_id in one variable and after do a for loop to insert this records in 
another table...


This code doesn't work. I obtain this error:
Exception: Multiple rows returned for Database.get() query

How can I retrieve this multiple rows and then process everyone of them at one 
time?

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


How can i create a random array of floats from 0 to 5 in python

2013-03-12 Thread Norah Jones
I want to create a random float array of size 100, with the values in the array 
ranging from 0 to 5. I have tried random.sample(range(5),100) but that does not 
work. How can i get what i want to achieve?

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


Finding the Min for positive and negative in python 3.3 list

2013-03-12 Thread Norah Jones
For example:
a=[-15,-30,-10,1,3,5]

I want to find a negative and a positive minimum.

example: negative
print(min(a)) = -30
 
positive
print(min(a)) = 1

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