Difference between revisions of "User:Diggernet/Sandbox"

From Gramps
Jump to: navigation, search
(GRAMPS 2.2)
(Changing Operating System)
Line 127: Line 127:
  
  
==Changing Operating System==
 
Write something here...
 
  
  
 
==GRAMPS 2.2==
 
==GRAMPS 2.2==
 
The instructions and scripts here are intended for use with GRAMPS 3.0.  A similar technique could be used with GRAMPS 2.2, but doing so is discouraged due to the risk of [[Recover corrupted grdb|database corruption]], especially on Linux.
 
The instructions and scripts here are intended for use with GRAMPS 3.0.  A similar technique could be used with GRAMPS 2.2, but doing so is discouraged due to the risk of [[Recover corrupted grdb|database corruption]], especially on Linux.

Revision as of 06:14, 26 March 2008

Run GRAMPS from a portable drive


Some users want to keep their GRAMPS data on a removable drive, either for portability between computers or for security. This document describes how to accomplish that, and should work whether using a floppy disk, a flash drive, or an external hard drive. Unfortunately, there are no easy instructions for installing GRAMPS and its dependencies on a removable drive, so these instructions assume and require that GRAMPS be installed on any computer to which you connect the drive.

Gnome-important.png
Make Regular Backups

Since removable drives can be more fragile and more easily lost than the hard drive in your computer, be sure to make regular backups of your data if you use this technique. For that matter, you should always make regular backups of important data anyway, because stuff can happen to your hard drive, too. But be especially careful if your data is stored on floppies or flash drives.

What this does

The magic is done in scripts that you use to start GRAMPS. The scripts figure out the location of the directory they are run from, on your removable drive, then tell GRAMPS to use that directory as its home directory. They do that using the GRAMPSHOME environment variable, which GRAMPS checks to see if its home directory should be somewhere other than the user's home directory. GRAMPS will then read and write its configuration and data to a subdirectory named gramps in directory that contains these scripts.

Installation

Save the scripts below in the directory you want to use as your GRAMPS home directory on the removable drive. When run, the scripts will direct GRAMPS to the directory they are installed in. Edit the SETTINGS section of the scripts you will use, so that the values there are correct for your computer.

You will probably need to change the media base path setting in GRAMPS each time you run it on a different computer. You may also need to edit some settings in the scripts for different computers. If there are certain computers which you use regularly that need different settings in the scripts, you can easily make separate script copies for each one, to avoid the need to reedit them.

Windows

gramps.bat

@echo off

REM Make changes to environment variables local to this block
setlocal

REM START OF SETTINGS

set PYTHON_COMMAND=C:\Python25\pythonw.exe
set GRAMPS_DIR=C:\Program Files\gramps

REM END OF SETTINGS

REM Set GRAMPSHOME to the drive and path of this script
set GRAMPSHOME=%~dp0
REM Go to this script location for good measure
%~d0
cd "%~p0"
REM Run GRAMPS
"%PYTHON_COMMAND" "%GRAMPS_DIR\gramps.py"

REM End the local environment block
endlocal

Usage

  1. Make sure GRAMPS is installed and working on the target computer.
  2. Attach your drive to the target computer.
  3. If necessary, edit the settings in this batch file (or a copy of it) to match the target computer.
  4. Edit gramps/keys.ini and remove database-path from the [behavior] section, if present.
  5. Double click the batch file to run GRAMPS.
  6. If necessary, edit the media base path in GRAMPS to match your removable drive.

How it works

The setlocal command tells Windows that you want to use a temporary copy of the environment that will be discarded later. The endlocal command tells Windows to go ahead and throw away that temporary environment. What this does is ensure that any changes made to the environment in the script (especially to GRAMPSHOME) do not carry on past the end of the script.

Batch files use %0 to refer to the drive, path and name of the batch file itself. You can also insert codes to reference specific parts of the batch file location. For example, %~d0 refers to just the drive letter, and %~p0 refers to just the path. These codes can be combined. Thus, %~dp0 refers to the drive letter and path where the batch file is located. The batch file uses these to set the value of GRAMPSHOME, then change drive and directory to that location.

Once that is set up, the batch file runs GRAMPS.

Linux

gramps.sh

#!/bin/bash

# You MUST use the full path to this script when you run it.

# START OF SETTINGS

GRAMPS_COMMAND="/usr/bin/gramps"
DIRNAME_COMMAND="/usr/bin/dirname"

# END OF SETTINGS

# Go to this script location for good measure
cd `$DIRNAME_COMMAND "$0"`
# Set GRAMPSHOME to the path of this script
# Run GRAMPS
GRAMPSHOME=`$DIRNAME_COMMAND "$0"` "$GRAMPS_COMMAND" &

Usage

  1. Make sure GRAMPS is installed and working on the target computer.
  2. Attach your drive to the target computer and mount it.
  3. If necessary, edit the settings in this script (or a copy of it) to match the target computer.
  4. Edit gramps/keys.ini and remove database-path from the [behavior] section, if present.
  5. Run this script using its full path to run GRAMPS.
  6. If necessary, edit the media base path in GRAMPS to match your mount point.

How it works

This is a little less forgiving than the Windows version, because bash doesn't have the equivalent of the Windows %0 modifiers. $0 only contains exactly what was used to start the script, so if you don't use the full path to the script (for example, if it's on the search path), the script has no way to determine where it is located.

The script uses "dirname $0" to change directory to the location of this script, and to set the value of GRAMPSHOME.

Once that is set up, the script runs GRAMPS. Because the value of GRAMPSHOME is set on the same line as the command to run GRAMPS, that value is only used for that command and will not carry on past the end of the script.

Maemo

If Don gets GRAMPS ported to his Nokia N810, a variation of this script ought to work there, too. That would allow keeping the data on a flash drive, and switching back and forth between PC and N810 GRAMPS. Please, Don?  :)

Python and Database Versions

Benny Malengier

2008/3/20, Jonathan Hipkiss:

   Oh dear, that's bad news I think.  I am in the process of installing
   Gramps on a number of PCs at home ( a laptop and desktop ) so I can use
   either to update my stuff, but I'm saving the data files on a network share!
     From reading that page it sounds like that's a no no?

It is possible, but you have to tweak the code at the moment. Best is to use the .gramps format at the moment and export to .gramps at end, and import again before you start.

In upcoming version 3.0 (a .0 release might be available over the weekend) you can set the database position in the preferences of GRAMPS. If you then make sure to use the same !!!! python !!!! version from the same OS, it should be no problem to work from a network share. I say same python version as we use the bsddb engine of python for the database, so it might be important (no experience) to use the same engine to access the database, as the engine will run on your local PC. If you use different OS's this might be a problem. To know your version of bsddb on each PC, do the following in a terminal:

python
>>> import bsddb
>>> bsddb.__version__
'4.4.5.2'

The above is the version. The problem is the same as running data from a USB stick. A user is experimenting with this here: http://www.gramps-project.org/wiki/index.php?title=User:Diggernet/Sandbox You can help with setting up a dedicated wiki page for USB key or shared network hosting of the database (.grdb in 3.0 family trees) in GRAMPS.

Benny



GRAMPS 2.2

The instructions and scripts here are intended for use with GRAMPS 3.0. A similar technique could be used with GRAMPS 2.2, but doing so is discouraged due to the risk of database corruption, especially on Linux.