sfUtil
index
/home/sfscript/src/py_sforce/sflib/sfUtil.py

Copyright 2004 Chip Vanek, Magma Design Automation
 
   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at
 
       http://www.apache.org/licenses/LICENSE-2.0
 
   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
 
Simple function that can convert a 15 character salesforce ID string
to the case-safe 18-character version
  Chip Vanek (chip@upvia.com), Nov 1st, 2004

 
Modules
       
fcntl
os
re
string
sys
time
types

 
Functions
       
baseconvert(number, fromdigits, todigits)
convertChunk(chunk)
Used by convertId15ToId18
convertId15ToId18(id15)
cronLock(fname='sfwalkerDefault.lock')
A simple fcntl locking scheme to ensure that sfBranchWalkSF jobs
run via cron do not overlap.
 
We assume that if stdout has no tty attached, then the job is a cron
job (the most likely explanation by far)
 
We let the caller handle exceptions. If one is thrown, assume that locking
failed and caller should act accordingly.
 
Lock is released automatically (and lock file closed) when this script
exits.
enforceRollingRetentionPolicy(bkfDir, bkfBase, bkfExt, retainNum)
bkfDir - directory in which backups reside
bkfBase - the base name of the backup file (i.e., left of the dot)
bkfExt - the backup file extension (i.e., right of the dot)
retainNum - the number of backups to retain
 
Look into the the backup directory and prune backup archives that
we no longer wish to keep.
 
Files must be in the format of bkfDir/bkfBase-YYYYmmdd-HHMMSS.bkfExt
genBackupTimestampFilename(filebase, fileext)
Given a filename of the pattern base.ext, generate a backup filename
base-YYYYmmdd-HHMMSS.ext
inputLineFromCmdline(premsg=None, required=False)
Prompt for single-line input from the user and return entered test as
a string.
 
Parameters:
premsg - Text to print to the tty before prompting for input
inputTextFromCmdline(premsg=None)
Prompt for multi-line input from the user and return entered test as
a string.
 
Parameters:
premsg - Text to print to the tty before prompting for input
splitFilenameExtension(filename)
uniq(alist)

 
Data
        BASE10 = '0123456789'
BASE16 = '0123456789ABCDEF'
BASE2 = '01'
BASE8 = '01234567'
BINARY = '01'
DECIMAL = '0123456789'
HEX = '0123456789ABCDEF'
OCTAL = '01234567'
TRANSLATION_TABLE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ012345'