[ sEaGhOsT @ 23.09.2009. 18:37 ] @
Nisam siguran da li postujem u pravom forumu (ako sam pogresio prebacite temu o odgovarajuci), ali mislim da je problem koji imam vise vezan za FreeBSD nego za SVN ili Python. Imam post-commit skriptu koja je napisana u Python-u i koja nakon svakog commit-a na SVN update-uje samo promenjene fajlove, dakle ne update-uje ceo repository, skripta savrseno radi na Ubuntu Linux-u, ali kada je stavim na FreeBSD jednostavno odbija saradnju. Ispod je kod, koji kao sto sam vec napomenuo savrseno radi na Ubunut-u distribuciji. Kada u post-commit fajl ubacim bash skriptu za update-ovanje koja update-uje ceo repository, ona radi sasvim normalno, tako da mislim da je problem sa Python-om ili sa system-om. Svaka vrsta pomoci bila bi mi veoma korisna. Mislim da je skripta vrlo korisna i svako kome je potrebno ovako nesto moze slobodno da je koristi i modfikuje po svojim potrebama. Variable koje se nalaze u kodu promenjene su iz sigurnosnih razloga. Code: #!/usr/local/bin/python import os import sys import subprocess as sp import traceback from email.MIMEMultipart import MIMEMultipart from email.MIMEText import MIMEText import smtplib fromaddr = '[email protected]' toaddrs = '[email protected]' REPO_NAME = '/home/dev/repo' # REPOSITORY name !!!!!! def email(subj, msg): try: body = '\r\n'.join(("From: %s" % fromaddr, "To: %s" % toaddrs, "Subject: %s" % subj, "", msg)) server = smtplib.SMTP('smtp.google.com') server.login('[email protected]', 'test') server.sendmail(fromaddr, toaddrs, body) server.quit() except Exception, ex: print ex pass PATH = sys.argv[1] REV = sys.argv[2] # SVN Setup SVN = "/usr/local/bin/svn" SVNLOOK = "/usr/local/bin/svnlook" WATCH = "/" #Temporary checkout folder TMP_ROOT = '/home/dev/domains/test.com/public_html/area51' class SPError(Exception): def __init__(self, command, returncode, stdout, stderr): self.command = command self.returncode = returncode self.stdout = stdout self.stderr = stderr def __str__(self): return repr(self) def __repr__(self): mesg = """ COMMAND: %s RETURNCODE: %s STDOUT: %s STDERR: %s """ mesg = '\n'.join([t.lstrip() for t in mesg.strip().split('\n')]) print mesg % (self.command, self.returncode, self.stdout, self.stderr) return mesg % (self.command, self.returncode, self.stdout, self.stderr) def spcall(command, shell=False, input=None): pipe = sp.Popen(command, shell=shell, stdin=sp.PIPE, stdout=sp.PIPE, stderr=sp.PIPE) (stdout, stderr) = pipe.communicate(input=input) if pipe.returncode != 0: if isinstance(command, list): command = ' '.join(command) raise SPError(command, pipe.returncode, stdout, stderr) return (stdout, stderr) def files_changed(): (stdout, stderr) = spcall([SVNLOOK, "dirs-changed", PATH, "-r", REV]) lines = [] for line in stdout.split('\n'): if line.startswith(WATCH): lines.append(line) return lines def main(): try: files = files_changed() if len(files) == 0: print "No change." sys.exit(0) for line in files: os.chdir(TMP_ROOT) spcall([SVN, "update" , "%s%s" % (REPO_NAME, line)]) except SPError, inst: email("Post-Commit Subprocess Failure", repr(inst)) except: mesg = traceback.format_exc() email("Post-Commit Unknown Failure", mesg) if __name__ == '__main__': main() Hvala, |