def process_post(self, hookname, req): contents = req.args.get('hook-file-contents', None) if contents is None: return if os.linesep != CRLF: contents = os.linesep.join( contents.split(CRLF)) # form contents will have this filename = self.filename(hookname) if not os.path.exists(filename): if not iswritable(filename): add_warning(req, 'File "%s" not writable' % filename) return f = file(filename, 'w') print >> f, contents f.close() try: os.chmod(filename, self.mode) except: # won't work on winblows pass
def can_enable(self, hookname): return iswritable(self.filename(hookname))