05786f729e
git-svn-id: http://svn.sabayonlinux.org/projects/entropy/trunk@88 cd1c1023-2f26-0410-ae45-c471fc1f0318
58 lines
2.0 KiB
Python
58 lines
2.0 KiB
Python
#!/usr/bin/python
|
|
'''
|
|
# DESCRIPTION:
|
|
# generic tools for enzyme application
|
|
|
|
Copyright (C) 2007 Fabio Erculiani
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; if not, write to the Free Software
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
'''
|
|
|
|
|
|
import portage
|
|
import portage_const
|
|
|
|
from entropyConstants import *
|
|
from entropyTools import *
|
|
|
|
# Stolen from Porthole 0.5.0 - thanks for your help :-)
|
|
|
|
def getSyncTime():
|
|
"""gets and returns the timestamp info saved during
|
|
the last portage tree sync"""
|
|
lastSync = None
|
|
try:
|
|
f = open(etpConst['portagetreedir'] + "/metadata/timestamp")
|
|
data = f.read()
|
|
f.close()
|
|
if data:
|
|
try:
|
|
lastSync = (str(data).decode('utf_8').encode("utf_8",'replace'))
|
|
except:
|
|
try:
|
|
lastSync = (str(data).decode('iso-8859-1').encode('utf_8', 'replace'))
|
|
except:
|
|
print_warning("getSyncTime(): unknown encoding")
|
|
else:
|
|
print_warning("getSyncTime(): nothing to read")
|
|
except:
|
|
print_warning("getSyncTime(): empty Portage tree (first run?) or no timestamp to read")
|
|
|
|
|
|
# fetch the latest updates from Gentoo rsync mirrors
|
|
def sync():
|
|
print_info(green("syncing the Portage tree at: "+etpConst['portagetreedir']))
|
|
spawnCommand(vdbPORTDIR+"="+etpConst['portagetreedir']+" "+cdbEMERGE+" --sync")
|
|
|