Re: Check server type at runtime?
Ah, that sounds perfect -- thank you! On Aug 21, 10:56 am, Warren wrote: > On Aug 20, 6:15 am, Thomas Guettler wrote: > > > > > You could have a look at sys.argv > > That's what I do. It works great, though YMMV. > > Example: > > import sys > > DEVSERVER = "runserver" in sys.argv > > ... > > if DEVSERVER: > ... > else: > ... > > ... --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Check server type at runtime?
On Aug 20, 6:15 am, Thomas Guettler wrote: > > You could have a look at sys.argv > That's what I do. It works great, though YMMV. Example: import sys DEVSERVER = "runserver" in sys.argv ... if DEVSERVER: ... else: ... ... --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Check server type at runtime?
Wiadomość napisana w dniu 2009-08-20, o godz. 13:15, przez ringemup: > Oh, I wasn't asking about what physical server or what host the site > is running on. I was hoping someone could tell me a way to determine > at runtime whether it's running off the Django development server > (manage.py runserver) as opposed to Apache et al. > > > On Aug 20, 4:25 am, Andreas Madsack wrote: >> Hi, >> >> why not get the hostname of the system? >> >> import socket >> hostname = socket.gethostname() >> if hostname == 'srv01.example.com': >> SERVER='production' >> else: >> SERVER='testing' >> >> Kind regards, >> >> Andreas. >> >> On Wed, Aug 19, 2009 at 4:52 PM, Thomas Guettler >> wrote: >> >>> Hi, >> >>> AFAIK there is no such variable in settings.py. It would be nice >>> to have it. >>> In your company we use the variable STAGE. >> >>> ringemup schrieb: Is there any way to check at runtime whether Django is running on the development server? >> Thanks! Long ago I tried to check the value of os.environ['SERVER_SOFTWARE'], but I cann't recall if this was succesful. -- Artificial intelligence stands no chance against natural stupidity Jarek Zgoda, R&D, Redefine jarek.zg...@redefine.pl --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Check server type at runtime?
One question, three correct and differnt answers! You could have a look at sys.argv Thomas ringemup schrieb: > > Oh, I wasn't asking about what physical server or what host the site > is running on. I was hoping someone could tell me a way to determine > at runtime whether it's running off the Django development server > (manage.py runserver) as opposed to Apache et al. -- Thomas Guettler, http://www.thomas-guettler.de/ E-Mail: guettli (*) thomas-guettler + de --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Check server type at runtime?
Oh, I wasn't asking about what physical server or what host the site is running on. I was hoping someone could tell me a way to determine at runtime whether it's running off the Django development server (manage.py runserver) as opposed to Apache et al. On Aug 20, 4:25 am, Andreas Madsack wrote: > Hi, > > why not get the hostname of the system? > > import socket > hostname = socket.gethostname() > if hostname == 'srv01.example.com': > SERVER='production' > else: > SERVER='testing' > > Kind regards, > > Andreas. > > On Wed, Aug 19, 2009 at 4:52 PM, Thomas Guettler wrote: > > > Hi, > > > AFAIK there is no such variable in settings.py. It would be nice to have it. > > In your company we use the variable STAGE. > > > ringemup schrieb: > >> Is there any way to check at runtime whether Django is running on the > >> development server? > > >> Thanks! > > > -- > > Thomas Guettler,http://www.thomas-guettler.de/ > > E-Mail: guettli (*) thomas-guettler + de --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Check server type at runtime?
Hi, why not get the hostname of the system? import socket hostname = socket.gethostname() if hostname == 'srv01.example.com': SERVER='production' else: SERVER='testing' Kind regards, Andreas. On Wed, Aug 19, 2009 at 4:52 PM, Thomas Guettler wrote: > > Hi, > > AFAIK there is no such variable in settings.py. It would be nice to have it. > In your company we use the variable STAGE. > > ringemup schrieb: >> Is there any way to check at runtime whether Django is running on the >> development server? >> >> Thanks! > > > -- > Thomas Guettler, http://www.thomas-guettler.de/ > E-Mail: guettli (*) thomas-guettler + de > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Check server type at runtime?
Hi, AFAIK there is no such variable in settings.py. It would be nice to have it. In your company we use the variable STAGE. ringemup schrieb: > Is there any way to check at runtime whether Django is running on the > development server? > > Thanks! -- Thomas Guettler, http://www.thomas-guettler.de/ E-Mail: guettli (*) thomas-guettler + de --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Check server type at runtime?
Is there any way to check at runtime whether Django is running on the development server? Thanks! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---