[sobjects] update notifications system to 3.19 api
#!/usr/bin/pythonimportsysfromsubprocessimportcallassbp_call,Popen,PIPEfromurllibimporturlopenimportosfromosimportpathasosp,pardir,chdirdeffind_mercurial():print"trying to find mercurial from the command line ..."print'-'*20tryhg=sbp_call(['hg','--version'])iftryhg:print'mercurial seems to be unavailable, please install it'raiseprint'-'*20defhg_call(args):returnsbp_call(['hg']+args)returnhg_callBASE_URL='http://www.logilab.org/hg/'to_clone=['fyzz','yams','rql','logilab/common','logilab/constraint','logilab/database','logilab/devtools','logilab/mtconverter','cubes/blog','cubes/calendar','cubes/card','cubes/comment','cubes/datafeed','cubes/email','cubes/file','cubes/folder','cubes/forgotpwd','cubes/keyword','cubes/link','cubes/localperms','cubes/mailinglist','cubes/nosylist','cubes/person','cubes/preview','cubes/registration','cubes/rememberme','cubes/tag','cubes/vcsfile','cubes/zone']# a couple of functions to be used to explore available# repositories and cubesdeflist_repos(repos_root):assertrepos_root.startswith('http://')hgwebdir_repos=(repo.strip()forrepoinurlopen(repos_root+'?style=raw').readlines()ifrepo.strip())prefix=osp.commonprefix(hgwebdir_repos)return(repo[len(prefix):].strip('/')forrepoinhgwebdir_repos)deflist_all_cubes(base_url=BASE_URL):all_repos=list_repos(base_url)#search for cubesforrepoinall_repos:ifrepo.startswith('cubes'):to_clone.append(repo)defget_latest_debian_tag(path):proc=Popen(['hg','-R',path,'tags'],stdout=PIPE)out,_err=proc.communicate()forlineinout.splitlines():if'debian-version'inline:returnline.split()[0]defmain():iflen(sys.argv)==1:base_url=BASE_URLeliflen(sys.argv)==2:base_url=sys.argv[1]else:sys.stderr.write('usage %s [base_url]\n'%sys.argv[0])sys.exit(1)hg_call=find_mercurial()printlen(to_clone),'repositories will be cloned'base_dir=osp.normpath(osp.join(osp.dirname(__file__),pardir,pardir))chdir(base_dir)not_updated=[]forrepointo_clone:url=base_url+repoif'/'notinrepo:target_path=repoelse:assertrepo.count('/')==1,repodirectory,repo=repo.split('/')ifnotosp.isdir(directory):os.mkdir(directory)open(osp.join(directory,'__init__.py'),'w').close()target_path=osp.join(directory,repo)ifosp.exists(target_path):printtarget_path,'seems already cloned. Skipping it.'else:hg_call(['clone','-U',url,target_path])tag=get_latest_debian_tag(target_path)iftag:print'updating to',taghg_call(['update','-R',target_path,tag])else:not_updated.append(target_path)print"""CubicWeb dependencies and standard set of cubes have been fetched andupdate to the latest stable version.You should ensure your PYTHONPATH contains `%(basedir)s`.You might want to read the environment configuration section of the documentationat http://docs.cubicweb.org/admin/setup.html#environment-configurationYou can find more cubes at http://www.cubicweb.org.Clone them from `%(baseurl)scubes/` into the `%(basedir)s%(sep)scubes%(sep)s` directory.To get started you may read http://docs.cubicweb.org/tutorials/base/index.html."""%{'basedir':os.getcwd(),'baseurl':base_url,'sep':os.sep}ifnot_updated:sys.stderr.write('WARNING: The following repositories were not updated (no debian tag found):\n')forpathinnot_updated:sys.stderr.write('\t-%s\n'%path)if__name__=='__main__':main()