Djangp, Tika, API

2016-06-07 Thread Allison
I am trying to extract a plain text from pdfs using Apache Tika. I can use 
a python binding, python-tika, but somehow I am not sure it's an efficient 
way as some files can come up more than 25M. 

What I need is the extract text instead of sending the files themselves to 
the server side. The best scenario would be 'extract on the client using 
Tika and send that plain text to the server/Django'. How would i implement 
this?

Thanks, 

Ali

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5c9f042b-c0bb-410d-8dae-3de57397c8d4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Network scan tool.

2016-06-07 Thread Luis Zárate
Hi,

With your deadline is too difficult (impossible), but if you are a crack in
django and celery and nmap this tool could be useful
https://pypi.python.org/pypi/python-nmap


El martes, 7 de junio de 2016, James Schneider 
escribió:
>
>
> On Tue, Jun 7, 2016 at 6:01 AM, Mahesh Kss  wrote:
>>
>> Hi all,
>>
>>
>> Need some of your thoughts for the below mentioned exercise. I am
planning to do it using Django. But I am not sure where i can place the
python script which monitors the network for connected hosts.
>>
>> Kindly share your thoughts and questions. I need to complete this as
soon as possible(max 2weeks from now).
>>
>>
>> Scanning tool:
>> > Create a python script to extract and maintain list of all host names
connected to a network. There should be a mechanism to determine newly
added host in network (by maintaining new and old host list).
>> (You may use virtual machines as client systems preferably Linux
systems).
>> > This list of hosts should be moved to database.
>> > There should be an admin user across the network to access systems
remotely.
>> > There should be a provision in python script to reset password for
newly added hosts.
>> > The python script should then scan all the discovered systems in
network for the following information:
>> system name, operating system details, CPU details, RAM details, hard
disk details.
>> On each system, list of all major softwares found along with
installation directory, version, license expiry date, etc.
>> > All the extracted information should be stored in database.
>> > There should be a mechanism to delete unreachable host names from host
list and database.
>> > Create a python web interface to display this information from DB
nicely using graphs, charts, etc.
>>
>
> Not to disillusion you, but IMHO writing such an application within two
weeks is highly, highly improbable. Since you have a tight deadline, I'm
assuming this is either for a customer, or for a class assignment. Either
way, the timeline is too aggressive to be feasible for a production-ready
application (or really even a working alpha application).
> You might want to consider integrating with an existing monitoring system
(such as Nagios, monit, etc.) or perhaps a configuration management system
such as Ansible, SaltStack, Puppet, or Chef for communicating with the
hosts and handling discovery. It's unlikely that you'll reinvent the wheel
and come up with something better than any of those purpose-built packages
that have been in development for years. Unless of course you are doing
this for your own learning purposes (but I think not given the timeline).
> Django actually has a very small part to play in this entire application.
You'll probably need Celery to process the commands for adding/removing
hosts from the backend and other management tasks.
> If it were me, and since you have all Linux hosts, I would start with
Ansible (and Cobbler for the DB integration). I have limited experience
with it (I'm still researching it for my own purposes), but it should be
able to handle all of the requirements except for the last couple, which
Django should be able to handle (probably in combination with Celery).
> http://docs.ansible.com/ansible/developing_api.html
> http://docs.ansible.com/ansible/intro_dynamic_inventory.html
>
http://docs.celeryproject.org/en/latest/django/first-steps-with-django.html
>
> -James
>
> --
> You received this message because you are subscribed to the Google Groups
"Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/CA%2Be%2BciU6KDfXSkYX99ATFDDm%3DWf%2BPifnH-3vSgkw7fBoQd7SgQ%40mail.gmail.com
.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
"La utopía sirve para caminar" Fernando Birri

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAG%2B5VyOjvDV2rsCcMQKv0jsG9qe58ovFDriTAPxx71Z08zGmWg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Expiration date option

2016-06-07 Thread James Schneider
On Jun 7, 2016 1:35 PM, "'David Turner' via Django users" <
django-users@googlegroups.com> wrote:
>
> Being new to Django I have a problem which I am not able to resolve.
>
> I have a model which has the following fields:
> expiry_date = models.DateField(null=True, blank=True,)
> has_expired = models.BooleanField(verbose_name='Has Expired',
>default=True, )
>
> I need to keep expired items in the database for reporting purposes.
>
> My question is how do I  show only the non-expired items in my views.?
>
> Would the solution be via a model manager?
>
>

Probably, yes.

If you only need to filter out expired items in a single view, you may just
want to override/append the query set used in that single view with
filter(has_expired=False).

If you plan on needing this query filtering in multiple locations, then
you'll want to create a custom model manager method that includes the
desired filter.

On a side note, you may not need the has_expired fields at all if your
business logic dictates that any instance with an expiry_date that has
already passed should be considered expired. It would mitigate the need for
the extra logic to keep the has_expired field in sync with the expiry_date.
Otherwise you may end up with objects with an expiry_date in the future but
showing expired, and vice versa. I try to avoid those types of field
dependencies, and DB normalization purists will likely complain about it.

-James

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2Be%2BciVY43_D-9YF9PK_intnsEkd%2BRDJoSVr6h-O79%2BzP%2B3Gcg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: authenticate a user without databse

2016-06-07 Thread Stephen J. Butler
Another option is to do all the authentication in Apache and use the Django
RemoteUser backend. This would require writing an Apache authnz module to
talk to the c++ server, and adjusting your Apache configs to require
valid-user. Or, if not Apache, whatever server you are using.

Nothing about authentication would be handled at the Django level, but
authorization would still be.

https://docs.djangoproject.com/en/1.9/howto/auth-remote-user/

On Tue, Jun 7, 2016 at 4:27 PM, Michal Petrucha <
michal.petru...@konk.org> wrote:

> On Tue, Jun 07, 2016 at 01:44:29PM -0700, Daniel Wilcox wrote:
> > Two options:
> >
> > 1. Tie into Django Authentication
> >
> > You can make a custom authentication backend and do whatever you want for
> > authentication -- including talk over a named pipe and get the OK for
> users
> > if you like.
> >
> > With that you'll be able to use the login_required decorator.  To make a
> > authentication backend you will also need some kind of User object to
> pass
> > to the built-in login and logout functions -- which take care of marking
> > the session appropriately.
> >
> > Of course that bring up a couple other things like storing your session
> > data -- I presume it is happening currently a cached session then?  Or is
> > there a solution for getting sessions data elsewhere?  Anyway typically
> > only the session-id is stored in the cookie and the value is a pickled
> > dictionary if you need to dig into that.
> >
> > 2. c++ is handling users, and auth... and maybe sessions
> >
> > It sounds like this may be your situation.  In which case the appropriate
> > thing to do is to decorate your view functions to check if the requesting
> > session is logged in, and either redirect to login or call the view
> > function decorated.  You could use memcache or something like that to
> store
> > login creds somewhere django can read them directly -- otherwise you'll
> > probably be calling out to your named pipe on every request to one of
> these
> > views.
> >
> > From what I'm reading you'd want something like this -- where you fill
> in a
> > function to call out to your named pipe in 'named_pipe_auth_ok'.
> >
> > def my_required_login(view_func):
> > def return_func(*args, **kwargs):
> > assert args[0]
> > request = args[0]
> > session_id = request.session.session_id
> > if named_pipe_auth_ok(session_id):
> > return view_func(*args, **kwargs)
> > else:
> > return redirect('/some/login/url')
> > return return_func
> >
> > Sounds like fun, cheers,
> >
> > Daniel
>
> Hi Prabhat,
>
> Daniel's advice looks correct, but I wanted to add that it would most
> likely be a good idea to implement a custom authentication backend [1],
> and use as much of django.contrib.auth for the rest as possible. There
> are so many little details that you would have to take care of should
> you decide to implement everything on your own – session invalidation
> on login/logout, correct handling of login redirects, and whatnot.
>
> In the best case scenario, you'd end up reimplementing a big chunk of
> django.contrib.auth, only with your custom code, which will inevitably
> be less thoroughly tested; in the worst case, you'd be left with
> gaping security holes that are easy to exploit.
>
> The possibility of plugging custom authentication backends into
> django.contrib.auth exists for use cases just like yours. It's the
> smart thing to do.
>
> Good luck,
>
> Michal
>
>
> [1]:
> https://docs.djangoproject.com/en/1.9/topics/auth/customizing/#writing-an-authentication-backend
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/20160607212741.GY29054%40konk.org
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAD4ANxWhJ8AmK4gg%3DWyyPfeVoZWWOHhAiGSoCL4fZkdnjw2hRQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: authenticate a user without databse

2016-06-07 Thread Michal Petrucha
On Tue, Jun 07, 2016 at 01:44:29PM -0700, Daniel Wilcox wrote:
> Two options:
> 
> 1. Tie into Django Authentication
> 
> You can make a custom authentication backend and do whatever you want for
> authentication -- including talk over a named pipe and get the OK for users
> if you like.
> 
> With that you'll be able to use the login_required decorator.  To make a
> authentication backend you will also need some kind of User object to pass
> to the built-in login and logout functions -- which take care of marking
> the session appropriately.
> 
> Of course that bring up a couple other things like storing your session
> data -- I presume it is happening currently a cached session then?  Or is
> there a solution for getting sessions data elsewhere?  Anyway typically
> only the session-id is stored in the cookie and the value is a pickled
> dictionary if you need to dig into that.
> 
> 2. c++ is handling users, and auth... and maybe sessions
> 
> It sounds like this may be your situation.  In which case the appropriate
> thing to do is to decorate your view functions to check if the requesting
> session is logged in, and either redirect to login or call the view
> function decorated.  You could use memcache or something like that to store
> login creds somewhere django can read them directly -- otherwise you'll
> probably be calling out to your named pipe on every request to one of these
> views.
> 
> From what I'm reading you'd want something like this -- where you fill in a
> function to call out to your named pipe in 'named_pipe_auth_ok'.
> 
> def my_required_login(view_func):
> def return_func(*args, **kwargs):
> assert args[0]
> request = args[0]
> session_id = request.session.session_id
> if named_pipe_auth_ok(session_id):
> return view_func(*args, **kwargs)
> else:
> return redirect('/some/login/url')
> return return_func
> 
> Sounds like fun, cheers,
> 
> Daniel

Hi Prabhat,

Daniel's advice looks correct, but I wanted to add that it would most
likely be a good idea to implement a custom authentication backend [1],
and use as much of django.contrib.auth for the rest as possible. There
are so many little details that you would have to take care of should
you decide to implement everything on your own – session invalidation
on login/logout, correct handling of login redirects, and whatnot.

In the best case scenario, you'd end up reimplementing a big chunk of
django.contrib.auth, only with your custom code, which will inevitably
be less thoroughly tested; in the worst case, you'd be left with
gaping security holes that are easy to exploit.

The possibility of plugging custom authentication backends into
django.contrib.auth exists for use cases just like yours. It's the
smart thing to do.

Good luck,

Michal


[1]: 
https://docs.djangoproject.com/en/1.9/topics/auth/customizing/#writing-an-authentication-backend

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/20160607212741.GY29054%40konk.org.
For more options, visit https://groups.google.com/d/optout.


signature.asc
Description: Digital signature


Re: authenticate a user without databse

2016-06-07 Thread Daniel Wilcox
Two options:

1. Tie into Django Authentication

You can make a custom authentication backend and do whatever you want for
authentication -- including talk over a named pipe and get the OK for users
if you like.

With that you'll be able to use the login_required decorator.  To make a
authentication backend you will also need some kind of User object to pass
to the built-in login and logout functions -- which take care of marking
the session appropriately.

Of course that bring up a couple other things like storing your session
data -- I presume it is happening currently a cached session then?  Or is
there a solution for getting sessions data elsewhere?  Anyway typically
only the session-id is stored in the cookie and the value is a pickled
dictionary if you need to dig into that.

2. c++ is handling users, and auth... and maybe sessions

It sounds like this may be your situation.  In which case the appropriate
thing to do is to decorate your view functions to check if the requesting
session is logged in, and either redirect to login or call the view
function decorated.  You could use memcache or something like that to store
login creds somewhere django can read them directly -- otherwise you'll
probably be calling out to your named pipe on every request to one of these
views.

>From what I'm reading you'd want something like this -- where you fill in a
function to call out to your named pipe in 'named_pipe_auth_ok'.

def my_required_login(view_func):
def return_func(*args, **kwargs):
assert args[0]
request = args[0]
session_id = request.session.session_id
if named_pipe_auth_ok(session_id):
return view_func(*args, **kwargs)
else:
return redirect('/some/login/url')
return return_func

Sounds like fun, cheers,

Daniel

On Mon, Jun 6, 2016 at 10:55 PM, prabhat jha 
wrote:

> hey bro thanx,but i am not using django authentication pattern.
> so @login required will not work in my condition.
>
>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/ab5a26dc-16a8-4638-9350-8f8ad26bf83d%40googlegroups.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAGq7Khri22_2F7X%2B_R6ZTvwFHnKpSroN6784UeKhZXijWc%3DKQQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Expiration date option

2016-06-07 Thread 'David Turner' via Django users
Being new to Django I have a problem which I am not able to resolve.

I have a model which has the following fields:
expiry_date = models.DateField(null=True, blank=True,) 
has_expired = models.BooleanField(verbose_name='Has Expired',
   default=True, )

I need to keep expired items in the database for reporting purposes.

My question is how do I  show only the non-expired items in my views.?

Would the solution be via a model manager?

Any help would be appreciated

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/fde03894-1d20-4977-906b-6cc1fcc02745%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Use of sphinx roles with django.contrib.admindocs

2016-06-07 Thread Adrian Lloyd Flanagan
First, apologies if this is documented elsewhere. I don't use Google Groups 
a lot, and I'm rather appalled at the search interface.

At any rate, I've added "django.contrib.admindocs" to my INSTALLED_APPS and 
done all the other things to get /admin/docs to be automatically generated. 
Mostly, it's pretty nice. The custom tags, like ':model:', seem to work 
fine.

However, I can't find a way to get it to recognize Sphinx tags like 
':class:' or ':meth:'. Do I have to choose between the convenience of 
admindocs and the standard documentation capabilities of  Sphinx, or is 
there something I'm missing that allows the two to work together?

Thanks for any help, advice, etc.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7f026306-2777-4f63-9997-6856f4585f77%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Network scan tool.

2016-06-07 Thread James Schneider
On Tue, Jun 7, 2016 at 6:01 AM, Mahesh Kss  wrote:

>
> Hi all,
>
>
> Need some of your thoughts for the below mentioned exercise. I am planning
> to do it using Django. But I am not sure where i can place the python
> script which monitors the network for connected hosts.
>
> Kindly share your thoughts and questions. I need to complete this as soon
> as possible(max 2weeks from now).
>
>
> Scanning tool:
> > Create a python script to extract and maintain list of all host names
> connected to a network. There should be a mechanism to determine newly
> added host in network (by maintaining new and old host list).
> (You may use virtual machines as client systems preferably Linux systems).
> > This list of hosts should be moved to database.
> > There should be an admin user across the network to access systems
> remotely.
> > There should be a provision in python script to reset password for newly
> added hosts.
> > The python script should then scan all the discovered systems in network
> for the following information:
> system name, operating system details, CPU details, RAM details, hard disk
> details.
> On each system, list of all major softwares found along with installation
> directory, version, license expiry date, etc.
> > All the extracted information should be stored in database.
> > There should be a mechanism to delete unreachable host names from host
> list and database.
> > Create a python web interface to display this information from DB nicely
> using graphs, charts, etc.
>
>
Not to disillusion you, but IMHO writing such an application within two
weeks is highly, highly improbable. Since you have a tight deadline, I'm
assuming this is either for a customer, or for a class assignment. Either
way, the timeline is too aggressive to be feasible for a production-ready
application (or really even a working alpha application).

You might want to consider integrating with an existing monitoring system
(such as Nagios, monit, etc.) or perhaps a configuration management system
such as Ansible, SaltStack, Puppet, or Chef for communicating with the
hosts and handling discovery. It's unlikely that you'll reinvent the wheel
and come up with something better than any of those purpose-built packages
that have been in development for years. Unless of course you are doing
this for your own learning purposes (but I think not given the timeline).

Django actually has a very small part to play in this entire application.
You'll probably need Celery to process the commands for adding/removing
hosts from the backend and other management tasks.

If it were me, and since you have all Linux hosts, I would start with
Ansible (and Cobbler for the DB integration). I have limited experience
with it (I'm still researching it for my own purposes), but it should be
able to handle all of the requirements except for the last couple, which
Django should be able to handle (probably in combination with Celery).

http://docs.ansible.com/ansible/developing_api.html
http://docs.ansible.com/ansible/intro_dynamic_inventory.html
http://docs.celeryproject.org/en/latest/django/first-steps-with-django.html

-James

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2Be%2BciU6KDfXSkYX99ATFDDm%3DWf%2BPifnH-3vSgkw7fBoQd7SgQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: How to set default ordering to Lower case?

2016-06-07 Thread Neto
Thanks

Em terça-feira, 7 de junho de 2016 01:21:09 UTC-3, Simon Charette escreveu:
>
> Hi Neto,
>
> Ordering by expression (order_by(Lower('name')) is not supported yet but 
> it's
> tracked as a feature request[1].
>
> If we manage to allow transforms in `order_by()`[2] in the future you 
> should be
> able to define a ['name__lower'] ordering in the future but until then you
> have to use a combination of `annotate()` and `order_by()` on a custom 
> manager:
>
> class PersonManager(models.Manager):
> def get_queryset(self, *args, **kwargs):
> queryset = super(PersonManager, self).get_queryset(*args, **kwargs)
> return queryset.annotate(
> name_lower=Lower('name'),
> ).order_by('name_lower')
>
> class Person(models.Model):
> name = models.CharField(_('name'), max_length=100)
>
> objects = PersonManager()
>
> Cheers,
> Simon
>
> [1] https://code.djangoproject.com/ticket/26257
> [2] https://code.djangoproject.com/ticket/24747 
>
> Le lundi 6 juin 2016 19:21:32 UTC-4, Neto a écrit :
>>
>> It does not works:
>>
>> from django.db.models.functions import Lower
>>
>>
>> class Person(models.Model):
>> 
>> name = models.CharField(_('name'), max_length=100)
>>
>> class Meta:
>> ordering = [Lower('name')]
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/61059ffb-32d9-4bab-a932-e48732f11083%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Network scan tool.

2016-06-07 Thread ludovic coues
There is two way to monitor the data.
Either passively, listening for each host saying hello on the network
or actively, probing for host at regular interval [1].

First way look like difficult as in requiring cooperation from diverse
host and relying on protocol like SNMP. Or you could listen for DHCP
message on the network.

The other way require to run a script at regular interval. For that
job, I would suggest Celery. Cron is the unix job for that tool but
celery is a python solution and integrate nicely with django.

Your project have quite an overlap with nagios. Especially for point
3, if you can interface with tools made to talk to nagios from client,
it will save you lot of trouble.

[1] If you want real time, there is an anecdote about diablo. The game
was turn-per-turn but the publisher wanted real time. Dev got twice
the money to turn it into real time. Dev simply reduced turn to 200ms.
Job done.

2016-06-07 15:01 GMT+02:00 Mahesh Kss :
>
> Hi all,
>
>
> Need some of your thoughts for the below mentioned exercise. I am planning
> to do it using Django. But I am not sure where i can place the python script
> which monitors the network for connected hosts.
>
> Kindly share your thoughts and questions. I need to complete this as soon as
> possible(max 2weeks from now).
>
>
> Scanning tool:
>> Create a python script to extract and maintain list of all host names
>> connected to a network. There should be a mechanism to determine newly added
>> host in network (by maintaining new and old host list).
> (You may use virtual machines as client systems preferably Linux systems).
>> This list of hosts should be moved to database.
>> There should be an admin user across the network to access systems
>> remotely.
>> There should be a provision in python script to reset password for newly
>> added hosts.
>> The python script should then scan all the discovered systems in network
>> for the following information:
> system name, operating system details, CPU details, RAM details, hard disk
> details.
> On each system, list of all major softwares found along with installation
> directory, version, license expiry date, etc.
>> All the extracted information should be stored in database.
>> There should be a mechanism to delete unreachable host names from host
>> list and database.
>> Create a python web interface to display this information from DB nicely
>> using graphs, charts, etc.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/d9e679ed-47be-40c3-9bfc-e065206e0d95%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



-- 

Cordialement, Coues Ludovic
+336 148 743 42

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAEuG%2BTYCixPVjkbiWSMR9b3ZxH-dR9Q-uV6Zs57RLU%3DHv8cJ-w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Network scan tool.

2016-06-07 Thread Mahesh Kss

Hi all,


Need some of your thoughts for the below mentioned exercise. I am planning 
to do it using Django. But I am not sure where i can place the python 
script which monitors the network for connected hosts.

Kindly share your thoughts and questions. I need to complete this as soon 
as possible(max 2weeks from now).


Scanning tool:
> Create a python script to extract and maintain list of all host names 
connected to a network. There should be a mechanism to determine newly 
added host in network (by maintaining new and old host list).
(You may use virtual machines as client systems preferably Linux systems).
> This list of hosts should be moved to database.
> There should be an admin user across the network to access systems 
remotely.
> There should be a provision in python script to reset password for newly 
added hosts.
> The python script should then scan all the discovered systems in network 
for the following information:
system name, operating system details, CPU details, RAM details, hard disk 
details.
On each system, list of all major softwares found along with installation 
directory, version, license expiry date, etc.
> All the extracted information should be stored in database.
> There should be a mechanism to delete unreachable host names from host 
list and database.
> Create a python web interface to display this information from DB nicely 
using graphs, charts, etc.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/d9e679ed-47be-40c3-9bfc-e065206e0d95%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How can I get mail to go out?

2016-06-07 Thread C.J.S. Hayward
I uninstalled postfix and installed sendmail; now, for the first time, a
password reset email went through.


Thanks,

On Tue, Jun 7, 2016 at 6:05 AM, C.J.S. Hayward <
christos.jonathan.hayw...@gmail.com> wrote:

> I have a Pinax installation where a classic Django "python manage.py
> send_mail doesn't seem to be working.
>
> I have a Debian server (Linux www 4.5.0-x86_64-linode65 #2 SMP Mon Mar 14
> 18:01:58 EDT 2016 x86_64 GNU/Linux), and postfix is installed.
>
> It is working at least far enough that if, from the command line, I type
> "echo foo | Mail __", it behaves predictably well and I receive
> the test email without problems.
>
> *However, the Django mail service on my Pinax installation seems to be a
> noop.* I have the following one-minute cron entry:
>
> * * * * * /home/cjsh/bin/__-mail
>
> The referenced script is:
>
> #!/bin/bash
> source /home/cjsh/__-env/bin/activate
> cd /home/cjsh/__
> python manage.py send_mail >> /tmp/__-mail.out 2>&1
>
> When I do a tail -f on the output file, and I do not do anything to
> generate a new email, the output makes sense:
>
> 
> acquiring lock...
> acquired.
> releasing lock...
> released.
>
> 0 sent; 0 deferred;
> done in 0.01 seconds
>
> And if I request a password reset to trigger sending a test email, the
> output looks like *that* is being handled appropriately, too:
>
> 
> acquiring lock...
> acquired.
> sending message 'Password reset e-mail sent' to _
> releasing lock...
> released.
>
> 1 sent; 0 deferred;
> done in 0.15 seconds
>
> But here's the problem. Although it reports an email is successfully sent,
> I have never seen an email sent by Pinax, including Gmail searches for
> "in:anywhere".
>
> What, if anything, can I do to either:
>
>1. Install packages so that Pinax will have everything it needs for
>routine Django "python manage.py send_mail" invocations to work, or
>2. Configure Pinax to go through my pobox or gmail account, or
>3. Do something else so that routine email notifications from Pinax go
>out?
>
> Thanks,
>
>
> --
> [image: Christos Jonathan Seth Hayward] 
> *C.J.S. Hayward *, a User Experience
> professional.
>
> Email  • Flagship Website 
>  • Github  • *LinkedIn
> * • Portfolio + More
>  • *Recent Title
> *
>  • Skills 
>
> Loads of talent and a thorough grounding in all major academic disciplines
> supporting User Experience.
>



-- 
[image: Christos Jonathan Seth Hayward] 
*C.J.S. Hayward *, a User Experience professional.

Email  • Flagship Website  •
Github  • *LinkedIn
* • Portfolio + More
 • *Recent Title
*
 • Skills 

Loads of talent and a thorough grounding in all major academic disciplines
supporting User Experience.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAE6_B5SKVRzRJeaka%2BrDh8o%2BLikPXdn%3DAkMwuu6Nr8mJR%2BGVxw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


How can I get mail to go out?

2016-06-07 Thread C.J.S. Hayward
I have a Pinax installation where a classic Django "python manage.py
send_mail doesn't seem to be working.

I have a Debian server (Linux www 4.5.0-x86_64-linode65 #2 SMP Mon Mar 14
18:01:58 EDT 2016 x86_64 GNU/Linux), and postfix is installed.

It is working at least far enough that if, from the command line, I type
"echo foo | Mail __", it behaves predictably well and I receive
the test email without problems.

*However, the Django mail service on my Pinax installation seems to be a
noop.* I have the following one-minute cron entry:

* * * * * /home/cjsh/bin/__-mail

The referenced script is:

#!/bin/bash
source /home/cjsh/__-env/bin/activate
cd /home/cjsh/__
python manage.py send_mail >> /tmp/__-mail.out 2>&1

When I do a tail -f on the output file, and I do not do anything to
generate a new email, the output makes sense:


acquiring lock...
acquired.
releasing lock...
released.

0 sent; 0 deferred;
done in 0.01 seconds

And if I request a password reset to trigger sending a test email, the
output looks like *that* is being handled appropriately, too:


acquiring lock...
acquired.
sending message 'Password reset e-mail sent' to _
releasing lock...
released.

1 sent; 0 deferred;
done in 0.15 seconds

But here's the problem. Although it reports an email is successfully sent,
I have never seen an email sent by Pinax, including Gmail searches for
"in:anywhere".

What, if anything, can I do to either:

   1. Install packages so that Pinax will have everything it needs for
   routine Django "python manage.py send_mail" invocations to work, or
   2. Configure Pinax to go through my pobox or gmail account, or
   3. Do something else so that routine email notifications from Pinax go
   out?

Thanks,


-- 
[image: Christos Jonathan Seth Hayward] 
*C.J.S. Hayward *, a User Experience professional.

Email  • Flagship Website  •
Github  • *LinkedIn
* • Portfolio + More
 • *Recent Title
*
 • Skills 

Loads of talent and a thorough grounding in all major academic disciplines
supporting User Experience.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAE6_B5Qe8Z-RAaN8rU05O9GE_f7RE6XbUALxrSsuFKS%3DuRpgqg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


How do I order a model, based on multiple values of a ManyToManyField?

2016-06-07 Thread Sem Verbraak


Basically, I need to order, based on multiple values from a ManyToManyField.


So what I want to achieve is having the objects with the most questioned 
values on top, continuing with objects that have less of the questioned 
values. Continuing with objects that don't have any of these values.


*The models:*



class Color(models.Model):
name = models.CharField(max_length=200)


class Item(models.Model):
surface_color = models.ManyToManyField(Color)


*The instances created which are based on the models above:*

   - Item 1) surface_color=[1, 2, 3]
   - Item 2) surface_color=[1, 2]
   - Item 3) surface_color=[2]
   - Item 4) surface_color=[1, 3]
   
*Now I need to order based multiple colors:*


Fake query: 
Item.objects.all().order_by(surface_color_id=[1, 3])

The query should have the following results:

   1. Item 4, since it has both 1 and 3 (2 matches)
   2. Item 1, since it has both 1 and 3 (2 matches)
   3. Item 2, since it has 1 (1 match)
   4. Item 3, since it has none (0 matches)
   
Is this possible with a single queryset? Or do I need to spam multiple 
queries for each combination?


The only things I found on the internet were about ordering multiple 
*fields*, this is about *values*.


Any help is appreciated.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/008e95a6-a04e-4bb1-a8e2-e5ee5ea632d8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django1.6 with uwsgi and nginx on RHEL 7

2016-06-07 Thread Avraham Serour
you just ran on your first problem for not using virtualenvs, I do hope you
won't run onto others, but in most cases it just means you aren't seeing
the problems yet.


On Tue, Jun 7, 2016 at 12:02 AM, Larry Martell 
wrote:

> In general, yes, I agree. But in this cast the machine is dedicated to
> just running that one app.
>
> On Mon, Jun 6, 2016 at 4:54 PM, Avraham Serour  wrote:
> > you should use isolated virtual environments for each python project,
> don't
> > install packages on the system wide python, see
> > https://virtualenv.pypa.io/en/stable/
> >
> >
> > On Mon, Jun 6, 2016 at 11:45 PM, Larry Martell 
> > wrote:
> >>
> >> I figured this out - the problem turned out to be that the RHEL 7
> >> machine had django 1.6.0 whereas the RHEL 6 machine had 1.6.10. Once I
> >> installed 1.6.10 on the 7 machine all was well.
> >>
> >> On Mon, Jun 6, 2016 at 12:50 PM, Larry Martell  >
> >> wrote:
> >> > I have successfully deployed django1.6 with uwsgi and nginx on RHEL6
> >> > but I cannot seem to get it working on RHEL7.
> >> >
> >> > I get Internal Server Error in the browser, and this in the uwsgi log:
> >> >
> >> > --- no python application found, check your startup logs for errors
> ---
> >> > [pid: 10582|app: -1|req: -1/2] xx.xx.xx.xx () {46 vars in 803 bytes}
> >> > [Mon Jun  6 11:58:50 2016] GET /favicon.ico => generated 21 bytes in 0
> >> > msecs (HTTP/1.1 500) 2 headers in 83 bytes (0 switches on core 0)
> >> >
> >> > I have tried everything I can think of. Where am I going wrong here?
> >> >
> >> > Here are my files:
> >> >
> >> > nginx config:
> >> >
> >> > upstream django {
> >> > server unix:///projects/elucid/elucid.sock; # for a file socket
> >> > }
> >> >
> >> > # configuration of the server
> >> > server {
> >> > # the port your site will be served on
> >> > listen  9004;
> >> > # the domain name it will serve for
> >> > server_name foo.bar.com;
> >> > charset utf-8;
> >> >
> >> > # max upload size
> >> > client_max_body_size 75M;   # adjust to taste
> >> >
> >> > # Django media
> >> > location /media  {
> >> > alias /projects/elucid/elucid/media;
> >> > }
> >> >
> >> > location /static {
> >> > alias /projects/elucid/static;
> >> > }
> >> >
> >> > # Finally, send all non-media requests to the Django server.
> >> > location / {
> >> > uwsgi_pass  django;
> >> > include /projects/elucid/elucid/uwsgi_params;
> >> > }
> >> > }
> >> >
> >> > /etc/uwsgi/sites/elucid_uwsgi.ini:
> >> >
> >> > # mysite_uwsgi.ini file
> >> > [uwsgi]
> >> >
> >> > # Django-related settings
> >> > # the base directory (full path)
> >> > chdir   = /projects/elucid
> >> > # Django's wsgi file
> >> > module  = elucid.wsgi
> >> > # the virtualenv (full path)
> >> > # home= /
> >> >
> >> > # process-related settings
> >> > # master
> >> > master  = true
> >> > # maximum number of worker processes
> >> > processes   = 10
> >> > # the socket (use the full path to be safe
> >> > socket  = /projects/elucid/elucid.sock
> >> > # ... with appropriate permissions - may be needed
> >> > chmod-socket= 666
> >> > # clear environment on exit
> >> > vacuum  = true
> >> > logto   = /var/log/uwsgi/error.log
> >> >
> >> > /etc/systemd/system/uwsgi.service:
> >> >
> >> > [Unit]
> >> > Description=uWSGI Emperor service
> >> >
> >> > [Service]
> >> > ExecStartPre=/usr/bin/bash -c 'mkdir -p /run/uwsgi; chown nginx
> >> > /run/uwsgi'
> >> > ExecStart=/usr/bin/uwsgi --emperor /etc/uwsgi/sites
> >> > Restart=always
> >> > KillSignal=SIGQUIT
> >> > Type=notify
> >> > NotifyAccess=all
> >> >
> >> > [Install]
> >> > WantedBy=multi-user.target
> >> >
> >> > wsgi.py:
> >> >
> >> > import os
> >> > from django.core.wsgi import get_wsgi_application
> >> > os.environ.setdefault("DJANGO_SETTINGS_MODULE", "elucid.settings")
> >> > application = get_wsgi_application()
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CACwCsY5eLv5fOpveu9-bJPzXCWUfVTQLUEwvH7rniATf_HqiEg%40mail.gmail.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at