#
# Sets up the Python settings
#
# Things to remember:
#    server: the live Perforce server.  The Demon will be run from here.
#    backup: the Perforce server that will be updated.  Must
#       not be live, or DB corruptions can occur.

POLL_INTERVAL = 2
P4API = False
DIE_ON_FATAL_ERROR = True

# details about the source server
class SERVER:
    host = "@P4D_HOST@"
    journal = "@P4D_JOURNAL@"
    
    # Location of the journal file.  The daemon will
    # append ".jnl.(sequencenumber)" (and .gz if it's compressed) to this
    # value.
    rotateJournal = "@P4D_ROTATE_JOURNAL@"

    # Indicates the last checkpoint the remote server was restored from.  Used
    # to know when to stop looking backwards through the Journal file.  If
    # this is set to None, then the daemon will use the value of the
    # p4 counter 'remote-checkpoint', and if this is a string, then the
    # daemon will use the value of the p4 counter with that as the counter name.
    lastCheckpoint = @LAST_CHECKPOINT@
    
    # location of executable files
    P4 = "@P4D_P4@"
    P4D = "@P4D_P4D@"
    RSYNC = "rsync"
    SSH = "ssh"
    SCP = "scp"
    
    # location of data files
    datadir = "@P4D_LOGDIR@"
    
    # map from the depot name to the directory on the local server.
    depotDirs = {@DEPOT_SETTINGS@
        #'depot': '/usr/local/perforce/db/depot'
    }
    
    # Environment variables for running Perforce commands
    # The environment variable P4ENV contains a list of environment variable
    # names to add
    P4ENV = {@P4ENV_SETTINGS@
    }
    
    P4CMD = (
        "@P4D_P4@",
        "-p", "@P4D_PORT@",
        "-u", "@P4D_ADMINUSER@",
        "-P", "@P4D_ADMINPASSWD@"
    )
    
    # Defines maximum Journal entries to send via SSH to the hot backup server
    # per SSH connection.
    # By increasing this value, you make the Daemon more performant by pushing
    # a larger collection of Journal lines to the remote server.  By decreasing
    # this value, you make the Daemon more defensive against critical failures.
    # If a critical failure happens to the logDaemon before these lines are
    # transmitted, they will be lost on the remote server.
    maxSSHLineTransfer = 5000
    
    # Defines maximum number of files to push over to the remote hot backup
    # server per RSync command.
    maxRSyncFileTransfer = 150
    
    pass

# details about the target server
class BACKUP:
    # hostname or IP address of the backup server
    host = "@P4D_REMOTEHOST@"
    
    # user on the remote host, which will connect via SSH.  An SSH Key
    # should be setup locally to allow for a non-password login.
    user = "@P4D_REMOTEUSER@"
    
    # map from the depot name to the directory on the remote server.
    depotDirs = {@REMOTEDEPOT_SETTINGS@
        #'depot': '/usr/local/perforce/db/depot'
    }
    
    # location of the P4D executable and any execution options
    P4D = ('@P4D_P4D@',
        '-r', '@P4D_REMOTEROOT@',
        '-J', '@P4D_JOURNAL@',
        '-L', '@P4D_LOG@'
        )
    
    # options for updating the journal from the live journal
    P4D_JOURNAL_OPTS = (
        '-f', '-jr',
        
        # read the fragment from stdin
        '-'
        )
    
    # Directory to store the checkpoint files that get copied from SERVER
    # for use in recovering from a checkpoint.
    # not needed at the moment
    # checkpointDir = '/var/p4d'
    
    pass
    
    
class LOGGING:
    # The log file for this demon process
    logfile = "@P4D_LOGDIR@/logDaemon.log"
    
    # the format for the time.  See
    #     http://python.org/doc/2.2.3/lib/module-time.html#strftime
    # for details on the format
    timeFormat = "[%Y-%m-%d %H:%M:%S] "
    
    # 0 = FATAL
    # 1 = ERR
    # 2 = WARN
    # 3 = INFO
    # 4 = VERBOSE
    # 5 = DEBUG
    logLevel = 5
    
    adminEmail = '@P4D_ADMIN_EMAIL@'
    emailLogLevel = 1
    emailSubjectPrefix = '[P4 Journal Daemon]'
    emailErrorSubject = 'Execution Error'
    emailSender = '@P4D_EMAIL@'
    emailReplyTo = '@P4D_EMAIL_REPLYTO@'
    smtpHost = '@P4D_SMTP_HOST@'
    
    
    pass


class JOURNAL:
    listeners = (
        'hotbackup.RemoteUpdateJournal',
        'hotbackup.RemoteUpdateDepot',
        'metadatasync.RetrieveMetaChanges'
        # 'review.EmailChanges'
        )
    pass


class METADATASYNC:
    # Map between the meta-data type and the path where it's located
    updateP4 = {
        'groups': '//depot/meta-data/groups/'
    }
    pass