2
# -*- coding: utf-8 -*-
10
__version__ = "$Revision$"
14
from desktopcouch.records.server import CouchDatabase
15
from desktopcouch.records.record import Record as CouchRecord
16
from core.stipple import PluginBase
18
database = CouchDatabase("packages", create=True)
20
RECORD_TYPE = 'http://www.okiebuntu.homelinux.com/packagesync'
21
ZSH_CONFIG = os.path.expanduser("~") + "/.zshrc"
23
class Plugin(PluginBase):
29
''' get simple list of installed apps to search for config files '''
30
search_string = commands.getoutput("dpkg --get-selections '*'")
31
if search_string.find("zsh") != -1:
32
''' write the zsh config to a couchdb '''
33
with open(ZSH_CONFIG, 'r') as zsh:
38
record_five = CouchRecord({ "_id" : "zsh" ,
39
"profile" : "user001" ,
43
record_type = RECORD_TYPE)
45
databaserecord = database.put_record(record_five)
48
print "Zsh is not installed SUCKER!"
52
map_js2 = 'function(doc){if (doc._id == "zsh"){emit(null,doc.file);}}'
53
database.add_view("zshconfig", map_js2, None, "getfile")
54
result = database.execute_view("zshconfig", "getfile")
57
config_iter = row.value
59
zsh_file = open(os.path.expanduser("~") + "/.zshrc2", 'w')
60
zsh_file.write(config_iter)