Hi all,

i have written a new version of fsvs-apt-hook for debian based systems.
This will now reuse the information written to apt/term.log and using
all lines "Setting up" / "Removing" / "Purge"
for the commit message. Unfortunately I havent found a way yet to get
the information about the commandline issued
but this is only minor.
What me bothers now is that when the list of installed packages is
really long I get error message:

> An error occurred: RA layer request failed (175002)
>   in ci__work: svn_ra_get_commit_editor: applying log message to
> //!svn/wbl/6ff1bf23-b789-46fe-b398-debf02dea90e/117: 400 Bad Request
> (https://fsvsp01.core.local)
This seems a problem with the commit message.
What is the maximum size of the commit message I can use for checkins?

Attached you can find current version of script.

------------------------------------------------------
http://fsvs.tigris.org/ds/viewMessage.do?dsForumId=3923&dsMessageId=1238595

To unsubscribe from this discussion, e-mail: [[email protected]].
#!/usr/bin/env python

import sys, commands
from os import stat
from os import path
import string

msg_prfx = 'fsvs-apt-hook_'

def filterSpecialChars(list):
  result = []
  for i in list:
    if ('Removing' in i) or ('Setting up' in i) or ('Purging' in i) or ('Configuring' in i):
      result.append(i)
  return result

def getLastAptLog():
  logfn = '/var/log/apt/term.log'
  try:
    FILE = open(logfn, 'r')
  except:
    print 'could not open file'
  lineList = FILE.readlines()
  length = len(lineList)
  FILE.close()
  result = []
  curline = lineList[-1]
  if 'Log ended:' in curline:
    cond = False
    i = 1
    while cond == False and (length-i)>0:
      i+=1
      curline = lineList[length-i]
      if not 'Log started:' in curline:
        result.insert(1,curline)
      else:
	cond = True
  msg = filterSpecialChars(result)
  msg.insert(0, msg_prfx + 'last-apt-action:\n')
  aptMsg = string.join(msg, '\r')
  print(aptMsg)
  quit()
  return(aptMsg)

def getDpkgFiles():
  cmd = 'dpkg-deb --contents %s' % pkg_file
  print cmd
  try:
    out = commands.getoutput(cmd)
  except:
    print 'exception running %s' % cmd
    exit()
  list = string.split(out, '\n')
  print list[1]

""" gets "fsvs st" state for working copy /
"""
def getFsvsStatus():
  cmd = 'fsvs st /'
  out = commands.getoutput(cmd)
  list = string.split(out, '\n')
  return list

def getConfigChanges():
  list = getFsvsStatus()
  if len(list) > 0:
    print('The following is a list of files that are changed on dpkg-tasks:')
    for i in list:
      print i
    res = raw_input('Do you want to commit these files? (y/N)')
    if res.lower() == 'y':
      return True
  else:
    return False

def ciConfigChanges(commitmsg):
  cmd = 'cd /;fsvs ci -m  \"%s\"' % commitmsg
  res = commands.getoutput(cmd) 
  print res

def checkFsvsEnviron():
  if not path.exists('/usr/bin/fsvs'):
    print msg_prfx + 'error: no instance of fsvs found'
    quit()
  """ check fsvs configuration
  """
  cmd = 'cd /;fsvs urls dump'
  if not len(commands.getoutput(cmd)) > 0:
    print msg_prfx + 'error: no urls defined for /'
    quit()
  """ check fsvs connectivitiy to repo
  """
  cmd = 'cd /;fsvs remote-status'
  if commands.getstatusoutput(cmd) == '1':
    print msg_prfx + 'error: no repo available'
    quit()
   
if __name__ == "__main__":
  checkFsvsEnviron()
  commitmsg = getLastAptLog()
  if getConfigChanges(): 
    ciConfigChanges(commitmsg)

Reply via email to