Check-in [d4f4a7b3f1]
Not logged in
Overview
Comment:Fixed running without config file
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: d4f4a7b3f1773771d7cab4f7d6e9684bd3dcf3fd
User & Date: vitus on 2015-11-09 18:29:25
Other Links: manifest | tags
Context
2015-11-10
08:05
Fixed start option check-in: 64171aea54 user: vitus tags: trunk
2015-11-09
18:29
Fixed running without config file check-in: d4f4a7b3f1 user: vitus tags: trunk
15:34
make some commands work. check-in: fa99d9b0d0 user: vitus tags: trunk
Changes

Modified vws from [90a91c6680] to [dd99cdcccb].

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
1
2
3
4
5
6
7
8

9
10
11
12
13
14
15








-







#!/usr/bin/python
from ConfigParser import ConfigParser
from argparse import ArgumentParser
import fcntl
import socket
import errno
import re
import os,sys
config=ConfigParser({"SharedVMs":"/var/cache/vws/shared","AutostartVMs":"/var/cache/vws/auto"})
def find_vm(name):
    search_path=[os.environ['HOME']+"/VWs",
        config.get("directories","SharedVMs"),
        config.get("directories","AutostartVMs")]
    for dirname in search_path:
        if name in os.listdir(dirname):
            return dirname+"/"+name
104
105
106
107
108
109
110

111
112
113
114
115
116
117
118

119


120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139


140
141
142
143
144
145
146
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140


141
142
143
144
145
146
147
148
149







+








+

+
+


















-
-
+
+








def cmd_usb_remove(options):
    raise NotImplementedError
def cmd_usb_attached(options):
    answer=send_command(options.sock,"info usb")
    print answer
def cmd_list(options):
    count = 0
    search_path=[os.environ['HOME']+"/VWs",
        config.get("directories","SharedVMs"),
        config.get("directories","AutostartVMs")]
    for dirname in search_path:
        if not os.access(dirname+"/.",os.X_OK):
            continue
        for vmname in os.listdir(dirname):
            if os.access(dirname+"/"+vmname+"/start",os.X_OK):
                count += 1
                print vmname
    if not count:
        sys.exit(1)
    
#
# Utility functions for arg parsing
#
def new_command(cmds,name,**kwargs):
    """
    Adds a subparser and adds a machine name argument to it
    """
    p=cmds.add_parser(name,**kwargs)
    p.add_argument('machine',type=str,help='name of vm to operate on')
    return p
#
# arg parsing
#



config=ConfigParser({'SharedVMs':'/var/cache/vws/shared',  
    'AuthoStartVMs':'/var/cache/vws/autostart'})

    'AutoStartVMs':'/var/cache/vws/autostart'})
config.add_section('directories')
config.read(['/etc/vws.conf',os.environ['HOME']+'/.vwsrc'])

args=ArgumentParser()
cmds=args.add_subparsers(dest='command',help="sub-command help")
p=cmds.add_parser("list",help="List existing VWs")
p.add_argument("--state",action='store_const',const=True,default=False,
                dest='state',help='Show state of the machine')