3
# writes data to the configuration files 'hosts' and 'options'
7
from os import system, environ, path, getenv, mkdir, getcwd
10
if not path.exists(getenv("HOME")+"/.pyNeighborhood"):
11
mkdir(getenv("HOME")+"/.pyNeighborhood")
13
if path.exists(getenv("HOME")+"/.pyNeighborhood"):
15
hostslocation = string.join([home, "/.pyNeighborhood"], '')
16
if not hostname == None:
17
os.chdir(hostslocation)
18
hostfile = open('hosts', 'a')
19
hostfile.write(hostname)
25
# check if ~/.pyNeighborhood exists. If not, create it
27
if not path.exists(getenv("HOME")+"/.pyNeighborhood"):
28
mkdir(getenv("HOME")+"/.pyNeighborhood")
30
if path.exists(getenv("HOME")+"/.pyNeighborhood"):
32
hostslocation = string.join([home, "/.pyNeighborhood"], '')
33
os.chdir(hostslocation)
36
#check if file containing a list of favourite hosts exists. If not, create it
37
hostfile = open('hosts', 'a')
40
#read hosts from file and create a standart list of them
41
hostfile = open("hosts", 'r')
43
list = hostfile.readlines()
49
hostline = line.split("\n")
50
hostlist.append(hostline[0])
53
#remove host from list
54
hostlist.remove(hostname)
58
#Clear the hostfile contents
59
hostfile = open('hosts', 'w')
62
#Write edited contents
63
for number in hostlist: