~bkrpr/bookliberator/trunk

« back to all changes in this revision

Viewing changes to utils/daily.py

  • Committer: Karl Fogel
  • Date: 2009-02-03 08:36:13 UTC
  • Revision ID: kfogel@red-bean.com-20090203083613-j2ur3grkth14e1zm
Start on a more formal system for release packaging.

* README: Add a version number.

* utils/: New directory.

* utils/targz.py: New file, copy of lp:bkrpr/utils/targz.py, revno 10.

* utils/daily.py: New file, copy of lp:bkrpr/utils/daily.py, revno 10.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python
 
2
 
 
3
'''
 
4
Archive a daily build of the trunk.
 
5
'''
 
6
 
 
7
import os, sys
 
8
import datetime
 
9
import util_mail
 
10
from targz import make_tgz
 
11
 
 
12
dest = "/home/james/bkrpr.org/download"
 
13
link = 'daily.tgz'
 
14
 
 
15
if not os.path.exists(dest):
 
16
    dest = os.getcwd()
 
17
link = dest + '/' + link
 
18
 
 
19
def try_daily(dest, n=3):
 
20
    try:
 
21
        today = datetime.date.today()
 
22
        tgz = dest + '/bkrpr-' + str(today) + '.tgz'
 
23
        revision = make_tgz(tgz)
 
24
        return tgz, revision
 
25
    except:
 
26
        if n == 1:
 
27
            raise
 
28
        else:
 
29
            return try_daily(dest, n-1)
 
30
 
 
31
def update_link(link, dest):
 
32
    '''Point link at dest, delete what it used to point at.'''
 
33
    try:
 
34
        curr_dest = os.readlink(link)
 
35
        os.remove(link)
 
36
        os.remove(curr_dest)
 
37
    except:
 
38
        pass
 
39
    os.symlink(dest, link)
 
40
 
 
41
def main():
 
42
    tgz, revision = try_daily(dest, 3)
 
43
    update_link(link, tgz)
 
44
 
 
45
if __name__ == '__main__':
 
46
    try:
 
47
        main()
 
48
    except:
 
49
        import traceback
 
50
        tb = traceback.format_exc()
 
51
        print tb
 
52
        sendMail('bkrpr@noreply.net','james@hackervisions.org','Bkrpr daily package failed',tb)