Merge pull request #1144 from niphlod/fix/external_folder

better support for -f
This commit is contained in:
mdipierro
2015-12-29 12:06:54 -06:00
2 changed files with 27 additions and 17 deletions
+1 -1
View File
@@ -120,7 +120,7 @@ args=()
class=handlers.RotatingFileHandler class=handlers.RotatingFileHandler
level=DEBUG level=DEBUG
formatter=simpleFormatter formatter=simpleFormatter
args=("logs/web2py.log", "a", 1000000, 5) args=("web2py.log", "a", 1000000, 5)
[handler_osxSysLogHandler] [handler_osxSysLogHandler]
class=handlers.SysLogHandler class=handlers.SysLogHandler
+26 -16
View File
@@ -150,7 +150,7 @@ class web2pyDialog(object):
self.scheduler_processes = {} self.scheduler_processes = {}
self.menu = Tkinter.Menu(self.root) self.menu = Tkinter.Menu(self.root)
servermenu = Tkinter.Menu(self.menu, tearoff=0) servermenu = Tkinter.Menu(self.menu, tearoff=0)
httplog = os.path.join(self.options.folder, 'httpserver.log') httplog = os.path.join(self.options.folder, self.options.log_filename)
iconphoto = os.path.join('extras', 'icons', 'web2py.gif') iconphoto = os.path.join('extras', 'icons', 'web2py.gif')
if os.path.exists(iconphoto): if os.path.exists(iconphoto):
img = Tkinter.PhotoImage(file=iconphoto) img = Tkinter.PhotoImage(file=iconphoto)
@@ -225,9 +225,9 @@ class web2pyDialog(object):
text=str(ProgramVersion + "\n" + ProgramAuthor), text=str(ProgramVersion + "\n" + ProgramAuthor),
font=('Helvetica', 11), justify=Tkinter.CENTER, font=('Helvetica', 11), justify=Tkinter.CENTER,
foreground='#195866', background=bg_color, foreground='#195866', background=bg_color,
height=3).pack( side='top', height=3).pack(side='top',
fill='both', fill='both',
expand='yes') expand='yes')
self.bannerarea.after(1000, self.update_canvas) self.bannerarea.after(1000, self.update_canvas)
@@ -322,11 +322,15 @@ class web2pyDialog(object):
self.tb = None self.tb = None
def update_schedulers(self, start=False): def update_schedulers(self, start=False):
applications_folder = os.path.join(self.options.folder, 'applications')
apps = [] apps = []
available_apps = [arq for arq in os.listdir('applications/')] ##FIXME - can't start scheduler in the correct dir from Tk
available_apps = [arq for arq in available_apps if self.options.folder:
if os.path.exists( return
'applications/%s/models/scheduler.py' % arq)] available_apps = [
arq for arq in os.listdir(applications_folder)
if os.path.exists(os.path.join(applications_folder, arq, 'models', 'scheduler.py'))
]
if start: if start:
# the widget takes care of starting the scheduler # the widget takes care of starting the scheduler
if self.options.scheduler and self.options.with_scheduler: if self.options.scheduler and self.options.with_scheduler:
@@ -414,9 +418,11 @@ class web2pyDialog(object):
def connect_pages(self): def connect_pages(self):
""" Connects pages """ """ Connects pages """
# reset the menu # reset the menu
available_apps = [arq for arq in os.listdir('applications/') applications_folder = os.path.join(self.options.folder, 'applications')
if os.path.exists( available_apps = [
'applications/%s/__init__.py' % arq)] arq for arq in os.listdir(applications_folder)
if os.path.exists(os.path.join(applications_folder, arq, '__init__.py'))
]
self.pagesmenu.delete(0, len(available_apps)) self.pagesmenu.delete(0, len(available_apps))
for arq in available_apps: for arq in available_apps:
url = self.url + arq url = self.url + arq
@@ -552,14 +558,15 @@ class web2pyDialog(object):
def update_canvas(self): def update_canvas(self):
""" Updates canvas """ """ Updates canvas """
httplog = os.path.join(self.options.folder, self.options.log_filename)
try: try:
t1 = os.path.getsize('httpserver.log') t1 = os.path.getsize(httplog)
except: except:
self.canvas.after(1000, self.update_canvas) self.canvas.after(1000, self.update_canvas)
return return
try: try:
fp = open('httpserver.log', 'r') fp = open(httplog, 'r')
fp.seek(self.t0) fp.seek(self.t0)
data = fp.read(t1 - self.t0) data = fp.read(t1 - self.t0)
fp.close() fp.close()
@@ -1051,6 +1058,8 @@ def start_schedulers(options):
apps = options.scheduler_groups apps = options.scheduler_groups
code = "from gluon import current;current._scheduler.loop()" code = "from gluon import current;current._scheduler.loop()"
logging.getLogger().setLevel(options.debuglevel) logging.getLogger().setLevel(options.debuglevel)
if options.folder:
os.chdir(options.folder)
if len(apps) == 1 and not options.with_scheduler: if len(apps) == 1 and not options.with_scheduler:
app_, code = get_code_for_scheduler(apps[0], options) app_, code = get_code_for_scheduler(apps[0], options)
if not app_: if not app_:
@@ -1118,11 +1127,12 @@ def start(cron=True):
setattr(options, key, getattr(options2, key)) setattr(options, key, getattr(options2, key))
logfile0 = os.path.join('examples', 'logging.example.conf') logfile0 = os.path.join('examples', 'logging.example.conf')
if not os.path.exists('logging.conf') and os.path.exists(logfile0): logfile1 = os.path.join(options.folder, 'logging.conf')
if not os.path.exists(logfile1) and os.path.exists(logfile0):
import shutil import shutil
sys.stdout.write("Copying logging.conf.example to logging.conf ... ") sys.stdout.write("Copying logging.conf.example to logging.conf ... ")
shutil.copyfile(logfile0, 'logging.conf') shutil.copyfile(logfile0, logfile1)
sys.stdout.write('OK\n') sys.stdout.write("OK\n")
# ## if -T run doctests (no cron) # ## if -T run doctests (no cron)
if hasattr(options, 'test') and options.test: if hasattr(options, 'test') and options.test: