view orpg/dirpath/dirpath_tools.py @ 183:0d9b746b5751 beta

Traipse Beta 'OpenRPG' {100115-00} Traipse is a distribution of OpenRPG that is designed to be easy to setup and go. Traipse also makes it easy for developers to work on code without fear of sacrifice. 'Ornery-Orc' continues the trend of 'Grumpy' and adds fixes to the code. 'Ornery-Orc's main goal is to offer more advanced features and enhance the productivity of the user. Update Summary (Beta) New Features: Added Bookmarks Added 'boot' command to remote admin Added confirmation window for sent nodes Minor changes to allow for portability to an OpenSUSE linux OS Miniatures Layer pop up box allows users to turn off Mini labels, from FlexiRPG Zoom Mouse plugin added Images added to Plugin UI Switching to Element Tree Map efficiency, from FlexiRPG Added Status Bar to Update Manager New TrueDebug Class in orpg_log (See documentation for usage) Portable Mercurial Tip of the Day added, from Core and community New Reference Syntax added for custom PC sheets New Child Reference for gametree New Parent Reference for gametree New Gametree Recursion method, mapping, context sensitivity, and effeciency.. New Features node with bonus nodes and Node Referencing help added Dieroller structure from Core New DieRoller portability for odd Dice Added 7th Sea die roller; ie [7k3] = [7d10.takeHighest(3).open(10)] New 'Mythos' System die roller added Added new vs. die roller method for WoD; ie [3v3] = [3d10.vs(3)]. Included for Mythos roller also New Warhammer FRPG Die Roller (Special thanks to Puu-san for the support) New EZ_Tree Reference system. Push a button, Traipse the tree, get a reference (Beta!) Fixes: Fix to Text based Server Fix to Remote Admin Commands Fix to Pretty Print, from Core Fix to Splitter Nodes not being created Fix to massive amounts of images loading, from Core Fix to Map from gametree not showing to all clients Fix to gametree about menus Fix to Password Manager check on startup Fix to PC Sheets from tool nodes. They now use the tabber_panel Fix to Whiteboard ID to prevent random line or text deleting. Fixes to Server, Remote Server, and Server GUI Fix to Update Manager; cleaner clode for saved repositories Fixes made to Settings Panel and now reactive settings when Ok is pressed Fixes to Alternity roller's attack roll. Uses a simple Tuple instead of a Splice Fix to Use panel of Forms and Tabbers. Now longer enters design mode Fix made Image Fetching. New fetching image and new failed image Modified ID's to prevent non updated clients from ruining the fix. default_manifest.xml renamed to default_upmana.xml
author sirebral
date Fri, 15 Jan 2010 23:01:42 -0600
parents 3b6888bb53b5
children 1df5912db00c
line wrap: on
line source

import sys
import os
import errno
from orpg.orpg_wx import *

if WXLOADED:
    class tmpApp(wx.App):
        def OnInit(self):
            return True

#-------------------------------------------------------
# void load_paths( dir_struct_reference )
# moved structure loading from dirpath.py by Snowdog 3-8-05
#-------------------------------------------------------
def load_paths(dir_struct, root_dir):
    dir_struct["home"] = root_dir + os.sep
    dir_struct["core"] = dir_struct["home"] + "orpg"+ os.sep
    dir_struct["data"] = dir_struct["home"] + "data"+ os.sep
    dir_struct["d20"] = dir_struct["data"] + "d20" + os.sep
    dir_struct["dnd3e"] = dir_struct["data"] + "dnd3e" + os.sep
    dir_struct["dnd35"] = dir_struct["data"] + "dnd35" + os.sep
    dir_struct["SWd20"] = dir_struct["data"] + "SWd20" + os.sep
    dir_struct["icon"] = dir_struct["home"] + "images" + os.sep
    dir_struct["template"] = dir_struct["core"] + "templates" + os.sep
    dir_struct["plugins"] = dir_struct["home"] + "plugins" + os.sep
    dir_struct["nodes"] = dir_struct["template"] + "nodes" + os.sep
    dir_struct["rollers"] = dir_struct["core"] + "dieroller" + os.sep + "rollers" + os.sep

    _userbase_dir = dir_struct["home"]
    _user_dir = dir_struct["home"] + "myfiles" + os.sep

    try:
        os.makedirs(_user_dir)
        os.makedirs(_user_dir + "runlogs" + os.sep);
        os.makedirs(_user_dir + "logs" + os.sep);
        os.makedirs(_user_dir + "webfiles" + os.sep);
    except OSError, e:
        if e.errno != errno.EEXIST: raise

    dir_struct["user"] = _user_dir
    dir_struct["logs"] = dir_struct["user"] + "logs" + os.sep

#-------------------------------------------------------
# int verify_home_path( directory_name )
# added by Snowdog 3-8-05
# updated with bailout code. Snowdog 7-25-05
#-------------------------------------------------------
def verify_home_path( path ):
    """checks for key ORPG files in the openrpg tree
       and askes for user intervention if their is a problem"""
    try:
        #verify that the root dir (as supplied) exists
        if not verify_file(path): return 0

        #These checks require that 'path' have a separator at the end.
        #Check and temporarily add one if needed
        if (path[(len(path)-len(os.sep)):] != os.sep):
            path = path + os.sep
        # These files should always exist at the root orpg dir
        check_files = ["orpg","data","images"]
        for n in range(len(check_files)):
            if not verify_file(path + check_files[n]): return 0
    except:
        # an error occured while verifying the directory structure
        # bail out with error signal
        return 0

    #all files and directories exist.
    return 1

#-------------------------------------------------------
# int verify_file( absolute_path )
# added by Snowdog 3-8-05
#-------------------------------------------------------
def verify_file(abs_path):
    """Returns True if file or directory exists"""
    try:
        os.stat(abs_path)
        return 1
    except OSError:
        #this exception signifies the file or dir doesn't exist
        return 0


#-------------------------------------------------------
# pathname get_user_help()
# added by Snowdog 3-8-05
# bug fix (SF #1242456) and updated with bailout code. Snowdog 7-25-05
#-------------------------------------------------------
## This can be removed in the future. TaS '09
def get_user_located_root():
    """Notify the user of directory problems
    and show directory selection dialog """

    if WXLOADED:
        app = tmpApp(0)
        app.MainLoop()

        dir = None
        try:
            msg = "OpenRPG cannot locate critical files.\nPlease locate the /System/ directory in the following window"
            alert= wx.MessageDialog(None,msg,"Warning",wx.OK|wx.ICON_ERROR)
            alert.Show()
            if alert.ShowModal() == wx.OK:
                alert.Destroy()
            dlg = wx.DirDialog(None, "Locate the System directory:",style=wx.DD_DEFAULT_STYLE)
            if dlg.ShowModal() == wx.ID_OK:
                dir = dlg.GetPath()
            dlg.Destroy()
            app.Destroy()
            return dir
        except Exception, e:
            print e
            print "OpenRPG encountered a problem while attempting to load file dialog to locate the OpenRPG root directory."
            print "please delete the files ./openrpg/orpg/dirpath/aproot.py and ./openrpg/orpg/dirpath/aproot.pyc and try again."
    else:
        dir = raw_input("Enter the full path to your openrpg folder:  ")
        return dir