Molly
Exe
Started by
FutbolMolly
, Jun 06 2008 12:06 PM
#1
Posted 06 June 2008 - 12:06 PM
Molly
#2
Posted 06 June 2008 - 05:15 PM
Ok, for my refrence.
You're trying to make a pyhton script that will start a server and open a website?
You want this to be an .exe?
Where is the server located? On the localhost?
Is this script going to run on this PC only?
Regards,
Olrik
You're trying to make a pyhton script that will start a server and open a website?
You want this to be an .exe?
Where is the server located? On the localhost?
Is this script going to run on this PC only?
Regards,
Olrik
#3
Posted 06 June 2008 - 07:57 PM
Artellos,
I already created the exe following the py2exe documentation. When I try to open it, the cmd just appears and goes away. I need for when someone clicks on the exe, the website to come up (my .py now is a webpage, just running on 127.0.0.1:8000). The script will run on other pc's but will not be public. It is going on a company's drive, that only people at the company can see. They won't let me create a website because of security. Hopefully I explained myself well, thanks for responding to me!!
Molly
I already created the exe following the py2exe documentation. When I try to open it, the cmd just appears and goes away. I need for when someone clicks on the exe, the website to come up (my .py now is a webpage, just running on 127.0.0.1:8000). The script will run on other pc's but will not be public. It is going on a company's drive, that only people at the company can see. They won't let me create a website because of security. Hopefully I explained myself well, thanks for responding to me!!
Molly
Edited by FutbolMolly, 06 June 2008 - 07:59 PM.
#4
Posted 07 June 2008 - 12:28 AM
I see, would you be able to share the sourcecode of the exe file?
simply use the following box.
Just to get it right in my head. You have an .exe that will run your hello.py script but it only opens a cmd and closes?
Regards,
Olrik
simply use the following box.
[code][/code
Im not sure what you mean with thisThey won't let me create a website because of security.
Just to get it right in my head. You have an .exe that will run your hello.py script but it only opens a cmd and closes?
Regards,
Olrik
#5
Posted 07 June 2008 - 08:16 AM
I should be able to share the source code, they are just being weird about it going out on the internet. When you say just use that code, what would that do??
Well when I say they won't let me make a website because of security, i mean that my boss does not know very much about computers and is afraid that somehow someone will find out all of the information being put on the website if it is out on the public.. So i told him that i could just put it on the company's drive and then they would be the only ones able to see it.
So I created my hello.py script and everything looks good, so to make it possible for me to put it on the .py drive, I made it into a .exe. Now when I click it, that is when the CMD just appears. So I think for it to work I need to add some code in that will launch the server and show it as a webpage.
I could be wrong though, I am really new to programming so sorry if I am confusing!!
Thanks!!
Molly
Well when I say they won't let me make a website because of security, i mean that my boss does not know very much about computers and is afraid that somehow someone will find out all of the information being put on the website if it is out on the public.. So i told him that i could just put it on the company's drive and then they would be the only ones able to see it.
So I created my hello.py script and everything looks good, so to make it possible for me to put it on the .py drive, I made it into a .exe. Now when I click it, that is when the CMD just appears. So I think for it to work I need to add some code in that will launch the server and show it as a webpage.
I could be wrong though, I am really new to programming so sorry if I am confusing!!
Thanks!!
Molly
#6
Posted 09 June 2008 - 08:11 AM
I made a test.py and put this code in it:
When I run it in the cmd, it works and my site comes up.
I then added the same thing to my actual code, and when I run it in the cmd I get these errors:
Thanks
Molly
import webbrowser webbrowser.open('http://127.0.0.1:8000/admin')
When I run it in the cmd, it works and my site comes up.
I then added the same thing to my actual code, and when I run it in the cmd I get these errors:
C:\Documents and Settings\MOZIMMERMA\Desktop\mycode>setup.py usage: setup.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...] or: setup.py --help [cmd1 cmd2 ...] or: setup.py --help-commands or: setup.py cmd --help error: no commands supplied C:\Documents and Settings\MOZIMMERMA\Desktop\mycode>models.py Traceback (most recent call last): File "C:\Documents and Settings\MOZIMMERMA\Desktop\mycode\models.py", line 1, in <module> from django.db import models File "C:\Python25\lib\site-packages\django\db\__init__.py", line 10, in <modul e> if not settings.DATABASE_ENGINE: File "C:\Python25\lib\site-packages\django\conf\__init__.py", line 28, in __ge tattr__ self._import_settings() File "C:\Python25\lib\site-packages\django\conf\__init__.py", line 57, in _imp ort_settings raise ImportError("Settings cannot be imported, because environment variable %s is undefined." % ENVIRONMENT_VARIABLE) ImportError: Settings cannot be imported, because environment variable DJANGO_SE TTINGS_MODULE is undefined.
Thanks
Molly
#7
Posted 09 June 2008 - 09:07 AM
Does Models.py have any code in it?
Is the only thing you need to do open that web page?
How are you making it into an exe?
How will the client PCs run the exe file? Through a task or a manual click?
Wouldn't it be easier to set the "homepage" to "127.0.0.1:8000/admin" ?
Just a few more questions
Regards,
Olrik
Is the only thing you need to do open that web page?
How are you making it into an exe?
How will the client PCs run the exe file? Through a task or a manual click?
Wouldn't it be easier to set the "homepage" to "127.0.0.1:8000/admin" ?
Just a few more questions
Regards,
Olrik
#8
Posted 09 June 2008 - 09:15 AM
Yes, this is models.py's code:
Yes, the only thing I need to do is for when people click on the file, for it to open up the webpage running at http://127.0.0.1:8000
I am making it into an exe by following this website:
http://www.pharscape...=...3&Itemid=51
The users will open it through a manual click
I am pretty sure that the homepage is already http://127.0.0.1:8000
I think that I am very close..
this is my setup.py
When i remove the setup(console = ["models.py"]), the website will run if i have the server running.
I think that I have to have that though, don't I??
How will the user's open it if the server is not running, because I manually go in and say run server.
Thanks Artellos
from django.db import models class Hazard(models.Model): name = models.CharField(max_length=100) def __unicode__(self): return self.name class Admin: pass class HazardType(models.Model): name = models.CharField(max_length=100) def __unicode__(self): return self.name class Admin: pass class HighwayType(models.Model): name = models.CharField(max_length=100) def __unicode__(self): return self.name class Admin: pass class Probability(models.Model): number = models.FloatField() name = models.CharField(max_length=100) funny_name = models.CharField(max_length=100) class Admin: pass def __unicode__(self): return '%s\t|\t%s\t|\t%s' % (self.number, self.name, self.funny_name) class Incident(models.Model): location = models.CharField(max_length=100) district = models.CharField(max_length=100) county = models.CharField(max_length=100) city = models.CharField(max_length=100) sr = models.CharField(max_length=100) seg = models.CharField(max_length=100) hazard = models.ForeignKey(Hazard) other_hazard_if_applicable = models.CharField(max_length=100) hazard_description = models.CharField(max_length=100) source_of_hazard = models.ForeignKey(SourceOfHazard) other_source = models.CharField(max_length=100) describe_conditions = models.CharField(max_length=100) highway_type = models.ForeignKey(HighwayType) adt = models.CharField(max_length=100) posted_speed_limit = models.CharField(max_length=100) site_distance = models.ForeignKey(SiteDistance) site_conditions = models.CharField(max_length=100) location_of_hazard_or_problem_relative_to_roadway = models.ForeignKey(LocationOfHazardOrProblemRelativeToRoadway) site_description = models.CharField(max_length=100) site_restrictions = models.CharField(max_length=100) photo_documentation = models.ForeignKey(PhotoDocumentation) geologic_setting = models.CharField(max_length=100) subsurface_conditions = models.CharField(max_length=100) surface_conditions = models.CharField(max_length=100) probability = models.ForeignKey(Probability) class Admin: list_display = ('location', 'district', 'hazard') list_filter = ('location', 'hazard', 'natural_vs_manmade') search_fields = ('hazard_description', 'district')
Yes, the only thing I need to do is for when people click on the file, for it to open up the webpage running at http://127.0.0.1:8000
I am making it into an exe by following this website:
http://www.pharscape...=...3&Itemid=51
The users will open it through a manual click
I am pretty sure that the homepage is already http://127.0.0.1:8000
I think that I am very close..
this is my setup.py
from distutils.core import setup import py2exe setup(console = ["models.py"]) import webbrowser webbrowser.open('http://127.0.0.1:8000/admin')
When i remove the setup(console = ["models.py"]), the website will run if i have the server running.
I think that I have to have that though, don't I??
How will the user's open it if the server is not running, because I manually go in and say run server.
Thanks Artellos
#9
Posted 09 June 2008 - 09:59 AM
Just 1 more question before I can give you some example code.
what does models.py do right now, What is it supposed to do?
You're close with py2exe, though you didn't completely get it.
I'll explain in the next post.
Regards,
Olrik
what does models.py do right now, What is it supposed to do?
You're close with py2exe, though you didn't completely get it.
I'll explain in the next post.
Regards,
Olrik
#10
Posted 09 June 2008 - 10:04 AM
Models.py is the code from the site. The site is supposed to be a place for Engineers to enter data about hazards that are happening on the road. Hope that makes sense..
Molly
Molly
#11
Posted 09 June 2008 - 10:41 AM
It does, sort of
Remember you might need to change 127.0.0.1:8000 to the appropriate IP address in the company.
Alright, lets start working on it then.
On the C:\ make a new folder called "pyweb" and make a new empty python file.
In the python file put the following code.
Now the next step is to make in installer python file.
Make another file and call it "setup.py"
Put the following code in
Now what we're going to do it make a simple batch file (Batch is basically a programming language built into windows that uses windows commands) that will compile the program "pyweb.py".
Make a new file and call it "compile.bat" and put the following code in there.
You have to make sure that you installed python properly and that python can be found in the systempath.
If you're not sure you can check simply by opening a Command Prompt and typing "python". If it brings up something looking like the code box below then you have it installed.
If python is not set into the system variables then follow the steps below:
NOTE: If you want the initial Command Prompt of the program to be hidden, rename the program to "pyweb.pyw" and in the setup.py edit the name to "pyweb.pyw". Setup.py should be left alone and so should the compile.bat
Regards,
Olrik
Remember you might need to change 127.0.0.1:8000 to the appropriate IP address in the company.
Alright, lets start working on it then.
On the C:\ make a new folder called "pyweb" and make a new empty python file.
In the python file put the following code.
import webbrowser webbrowser.open('http://127.0.0.1:8000/admin')Save it under the name "pyweb.py"
Now the next step is to make in installer python file.
Make another file and call it "setup.py"
Put the following code in
from distutils.core import setup import py2exe setup( windows = [ { "script": "pyweb.py", } ], )
Now what we're going to do it make a simple batch file (Batch is basically a programming language built into windows that uses windows commands) that will compile the program "pyweb.py".
Make a new file and call it "compile.bat" and put the following code in there.
python concealipsetup.py py2exe if errorlevel 1 pause
You have to make sure that you installed python properly and that python can be found in the systempath.
If you're not sure you can check simply by opening a Command Prompt and typing "python". If it brings up something looking like the code box below then you have it installed.
C:\Documents and Settings\Olrik>python Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>>
If python is not set into the system variables then follow the steps below:
- Right click "My Computer" and open the Properties.
- Go to "Advanced" and at the bottom click the button "Variables" (or something similar).
- Then in the bottom box find "path" and hit "Edit"
- Then hit the right arrow key to go to the last part of the line and type ";<pythondir>" where <pythondir> is the directory Python is found. For me that is "C:\python25"
NOTE: If you want the initial Command Prompt of the program to be hidden, rename the program to "pyweb.pyw" and in the setup.py edit the name to "pyweb.pyw". Setup.py should be left alone and so should the compile.bat
Regards,
Olrik
#12
Posted 09 June 2008 - 11:07 AM
Okay, that worked
Now i think I need to add to my code, somehow for the server to start automatically, because it opens the browser but will not open since the server is not running.
Thanks so much!
Molly
Now i think I need to add to my code, somehow for the server to start automatically, because it opens the browser but will not open since the server is not running.
Thanks so much!
Molly
#13
Posted 09 June 2008 - 11:08 AM
You're welcome
Regards,
Olrik
Regards,
Olrik
#14
Posted 09 June 2008 - 11:12 AM
Do you know how what code I need to add for the server to automatically start?? If you don't want to help, that okay because you already helped me out a lot and I am thankful for that!!
#15
Posted 09 June 2008 - 11:27 AM
It really depends, Is it a server with the site on it only?
How do the engineers usually access it?
How do you start the server?
Regards,
Olrik
How do the engineers usually access it?
How do you start the server?
Regards,
Olrik
Similar Topics
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users