I've had a bunch of different sage servers on one machine, and I
wanted to consolidate my worksheets. So I wrote the script below,
which might be useful to someone else. There is probably a better way
to do this, but I don't know what it is. Comments are appreciated,
I'm sure this can be improved. I know that there has been some recent
work on notebook administration that will be in 3.1.2 or 3.1.3, so
this could be quite outdated soon.
def worksheetcopier(source_dir, target_dir, username = 'admin'):
'''
Imports ALL of the worksheets from one notebook directory into
another.
'''
nb = load(target_dir + '/' + 'nb.sobj')
users = os.listdir(source_dir + '/worksheets')
users = [x for x in users if '_' not in x]
for auser in users:
w_list = os.listdir(source_dir + '/worksheets/'+auser)
w_list = [x for x in w_list if '_' not in x]
w_list = [x for x in w_list if '.' not in x]
for ws in w_list:
try:
nb.import_worksheet(source_dir + '/worksheets/'+auser+'/'+ws
+'/worksheet.txt',username)
except Exception, err:
print 'Error with user: ' + auser
print 'Error with worksheet name: ' + ws
print err
break
nb.save()
print 'all done.'
--M. Hampton
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sage-edu" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/sage-edu?hl=en
-~----------~----~----~----~------~----~------~--~---