Skip to content

Commit

Permalink
cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
ianmiell committed May 25, 2017
1 parent 5abbf27 commit 0a1f8cc
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 38 deletions.
6 changes: 2 additions & 4 deletions shutit_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,6 @@ def __init__(self,
#assert isinstance(self.delivery,str)
#assert isinstance(self.shutitfiles,list)
elif self.action == 'build' or self.action == 'list_configs' or self.action == 'list_modules':

self.push = push
self.export = export
self.save = save
Expand Down Expand Up @@ -3280,9 +3279,8 @@ def handle_skeleton(self, args):
'vagrant_docker': vagrant_docker
}
shutit_skeleton.create_skeleton(self)


# TODO: rationalise/tidy

def handle_run(self, args):
module_name = shutit_util.random_id(chars=string.ascii_letters)
module_dir = "/tmp/shutit_built/" + module_name
Expand Down Expand Up @@ -4387,6 +4385,7 @@ def log(self, msg, add_final_message=False, level=logging.INFO, transient=False,

# Pass through to global object
def create_session(self, session_type='bash', docker_image=None, rm=None):
self=self
return shutit_global.shutit_global_object.create_session(session_type=session_type, docker_image=docker_image, rm=rm)


Expand Down Expand Up @@ -4501,4 +4500,3 @@ def make_dep_graph(depender):
# --net argument to docker, eg "bridge", "none", "container:<name|id>" or "host". Empty means use default (bridge).
net:
'''

4 changes: 1 addition & 3 deletions shutit_patterns/bash.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
def setup_bash_pattern(shutit,
skel_path,
skel_delivery,
skel_pattern,
skel_domain,
skel_module_name,
skel_shutitfiles,
Expand Down Expand Up @@ -45,7 +44,7 @@ def setup_bash_pattern(shutit,
module_modifier = '_' + str(_count)
new_module_filename = skel_path + '/' + os.path.join(skel_module_name + module_modifier + '.py')
shutit.cfg['skeleton']['module_modifier'] = module_modifier
(sections, skel_module_id, skel_module_name, default_include, ok) = shutitfile.shutitfile_to_shutit_module(shutit, skel_shutitfile,skel_path,skel_domain,skel_module_name,skel_domain_hash,skel_delivery,skel_depends,_count,_total,module_modifier)
(sections, skel_module_id, skel_module_name, _, _) = shutitfile.shutitfile_to_shutit_module(shutit, skel_shutitfile,skel_path,skel_domain,skel_module_name,skel_domain_hash,skel_delivery,skel_depends,_count,_total,module_modifier)
shutit.cfg['skeleton']['header_section'] = sections['header_section']
shutit.cfg['skeleton']['config_section'] = sections['config_section']
shutit.cfg['skeleton']['build_section'] = sections['build_section']
Expand Down Expand Up @@ -178,4 +177,3 @@ def stop(self, shutit):
shutit.core.module.build:yes''')
build_cnf_file.close()
os.chmod(build_cnf_filename,0o400)

3 changes: 1 addition & 2 deletions shutit_patterns/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
def setup_docker_pattern(shutit,
skel_path,
skel_delivery,
skel_pattern,
skel_domain,
skel_module_name,
skel_shutitfiles,
Expand Down Expand Up @@ -164,7 +163,7 @@ def setup_docker_pattern(shutit,
module_modifier = '_' + str(_count)
new_module_filename = skel_path + '/' + os.path.join(skel_module_name + module_modifier + '.py')
shutit.cfg['skeleton']['module_modifier'] = module_modifier
(sections, skel_module_id, skel_module_name, default_include, ok) = shutitfile.shutitfile_to_shutit_module(shutit, skel_shutitfile,skel_path,skel_domain,skel_module_name,skel_domain_hash,skel_delivery,skel_depends,_count,_total,module_modifier)
(sections, skel_module_id, skel_module_name, _, _) = shutitfile.shutitfile_to_shutit_module(shutit, skel_shutitfile,skel_path,skel_domain,skel_module_name,skel_domain_hash,skel_delivery,skel_depends,_count,_total,module_modifier)
shutit.cfg['skeleton']['header_section'] = sections['header_section']
shutit.cfg['skeleton']['config_section'] = sections['config_section']
shutit.cfg['skeleton']['build_section'] = sections['build_section']
Expand Down
15 changes: 5 additions & 10 deletions shutit_patterns/shutitfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
from urlparse import urlparse
from urllib2 import urlopen
from six import iteritems
import shutit_util
import shutit_global
import shutit_skeleton

Expand All @@ -45,10 +44,7 @@ def setup_shutitfile_pattern(shutit,
skel_delivery,
skel_pattern,
skel_domain,
skel_module_name,
skel_shutitfiles,
skel_domain_hash,
skel_depends,
skel_module_name,
skel_vagrant_num_machines,
skel_vagrant_machine_prefix,
skel_vagrant_ssh_access,
Expand Down Expand Up @@ -246,7 +242,7 @@ def shutitfile_to_shutit_module(shutit,
check_shutitfile_representation(shutit, shutitfile_representation, skel_delivery)

# Get the shutit module as a string
sections, module_id, module_name, depends, default_include = generate_shutit_module_sections(shutit, shutitfile_representation, skel_domain, skel_module_name, skel_module_modifier, skel_shutitfile, skel_depends, order, total)
sections, module_id, _, depends, default_include = generate_shutit_module_sections(shutit, shutitfile_representation, skel_domain, skel_module_name, skel_module_modifier, skel_shutitfile, skel_depends, order, total)
if module_id == skel_module_name:
module_id = skel_domain + """.""" + skel_module_name + skel_module_modifier

Expand Down Expand Up @@ -307,7 +303,8 @@ def check_shutitfile_representation(shutit, shutitfile_representation, skel_deli

def generate_shutit_module_sections(shutit,
shutitfile_representation,
skel_domain, skel_module_name,
skel_domain,
skel_module_name,
skel_module_modifier,
skel_shutitfile,
skel_depends,
Expand Down Expand Up @@ -518,7 +515,7 @@ def handle_shutitfile_config_line(line):
assert shutitfile_command in ('CONFIG','CONFIG_SECRET'), '%r is not a handled config command' % shutitfile_command
if shutitfile_command in ('CONFIG','CONFIG_SECRET'):
shutitfile_args = parse_shutitfile_args(line[1])
assert type(shutitfile_args) in (dict,list)
assert isinstance(shutitfile_args, (dict,list))
if shutitfile_command == 'CONFIG':
secret_str = 'False'
elif shutitfile_command == 'CONFIG_SECRET':
Expand Down Expand Up @@ -874,5 +871,3 @@ def shutitfile_get_section(shutitfile_command, current):
else:
return 'build'
return current


3 changes: 1 addition & 2 deletions shutit_patterns/vagrant.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
def setup_vagrant_pattern(shutit,
skel_path,
skel_delivery,
skel_pattern,
skel_domain,
skel_module_name,
skel_shutitfiles,
Expand Down Expand Up @@ -255,7 +254,7 @@ def get_config(self, shutit):
module_modifier = '_' + str(_count)
new_module_filename = skel_path + '/' + os.path.join(skel_module_name + module_modifier + '.py')
shutit.cfg['skeleton']['module_modifier'] = module_modifier
(sections, skel_module_id, skel_module_name, default_include, ok) = shutitfile.shutitfile_to_shutit_module(shutit, skel_shutitfile,skel_path,skel_domain,skel_module_name,skel_domain_hash,skel_delivery,skel_depends,_count,_total,module_modifier)
(sections, skel_module_id, skel_module_name, _, _) = shutitfile.shutitfile_to_shutit_module(shutit, skel_shutitfile,skel_path,skel_domain,skel_module_name,skel_domain_hash,skel_delivery,skel_depends,_count,_total,module_modifier)
shutit.cfg['skeleton']['header_section'] = sections['header_section']
shutit.cfg['skeleton']['config_section'] = sections['config_section']
shutit.cfg['skeleton']['build_section'] = sections['build_section']
Expand Down
1 change: 0 additions & 1 deletion shutit_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

import logging
import shutit_global
from shutit_module import ShutItModule
from shutit_sendspec import ShutItSendSpec
Expand Down
16 changes: 4 additions & 12 deletions shutit_skeleton.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ def create_skeleton(shutit):
bash.setup_bash_pattern(shutit,
skel_path=skel_path,
skel_delivery=skel_delivery,
skel_pattern=skel_pattern,
skel_domain=skel_domain,
skel_module_name=skel_module_name,
skel_shutitfiles=skel_shutitfiles,
Expand All @@ -80,7 +79,6 @@ def create_skeleton(shutit):
docker.setup_docker_pattern(shutit,
skel_path=skel_path,
skel_delivery=skel_delivery,
skel_pattern=skel_pattern,
skel_domain=skel_domain,
skel_module_name=skel_module_name,
skel_shutitfiles=skel_shutitfiles,
Expand All @@ -91,7 +89,6 @@ def create_skeleton(shutit):
vagrant.setup_vagrant_pattern(shutit,
skel_path=skel_path,
skel_delivery=skel_delivery,
skel_pattern=skel_pattern,
skel_domain=skel_domain,
skel_module_name=skel_module_name,
skel_shutitfiles=skel_shutitfiles,
Expand All @@ -108,9 +105,6 @@ def create_skeleton(shutit):
skel_pattern=skel_pattern,
skel_domain=skel_domain,
skel_module_name=skel_module_name,
skel_shutitfiles=skel_shutitfiles,
skel_domain_hash=skel_domain_hash,
skel_depends=skel_depends,
skel_vagrant_num_machines=skel_vagrant_num_machines,
skel_vagrant_machine_prefix=skel_vagrant_machine_prefix,
skel_vagrant_ssh_access=skel_vagrant_ssh_access,
Expand Down Expand Up @@ -179,7 +173,7 @@ def process_shutitfile(shutit, shutitfile_contents):
# Put in the run.sh.
try:
shutitfile_representation['shutitfile']['volume'].append(' '.join(json.loads(item[1])))
except Exception:
except NameError:
shutitfile_representation['shutitfile']['volume'].append(item[1])
elif shutitfile_command == 'EXPOSE':
# TESTED? NO
Expand All @@ -190,14 +184,14 @@ def process_shutitfile(shutit, shutitfile_contents):
# Put in the run.sh? Yes, if it exists it goes at the front of cmd
try:
shutitfile_representation['shutitfile']['entrypoint'] = ' '.join(json.loads(item[1]))
except Exception:
except NameError:
shutitfile_representation['shutitfile']['entrypoint'] = item[1]
elif shutitfile_command == 'CMD':
# TESTED? NO
# Put in the run.sh
try:
shutitfile_representation['shutitfile']['cmd'] = ' '.join(json.loads(item[1]))
except Exception:
except NameError:
shutitfile_representation['shutitfile']['cmd'] = item[1]
# Other items to be run through sequentially (as they are part of the script)
elif shutitfile_command == 'GET_PASSWORD':
Expand All @@ -219,7 +213,7 @@ def process_shutitfile(shutit, shutitfile_contents):
# Only handle simple commands for now and ignore the fact that shutitfiles run with /bin/sh -c rather than bash.
try:
shutitfile_representation['shutitfile']['script'].append([shutitfile_command, ' '.join(json.loads(item[1]))])
except Exception:
except NameError:
shutitfile_representation['shutitfile']['script'].append([shutitfile_command, item[1]])
elif shutitfile_command == 'ASSERT_OUTPUT':
if last_shutitfile_command not in ('RUN','SEND'):
Expand Down Expand Up @@ -270,5 +264,3 @@ def process_shutitfile(shutit, shutitfile_contents):
shutit.fail('shutitfile command: ' + shutitfile_command + ' not processed') # pragma: no cover
last_shutitfile_command = shutitfile_command
return shutitfile_representation, True


4 changes: 0 additions & 4 deletions shutit_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,6 @@ def util_raw_input(prompt='', default=None, ispass=False, use_readline=True):
return default




def get_input(msg, default='', valid=None, boolean=False, ispass=False, colour='32'):
"""Gets input from the user, and returns the answer.
Expand All @@ -296,5 +294,3 @@ def get_input(msg, default='', valid=None, boolean=False, ispass=False, colour='
return default
else:
return answer


0 comments on commit 0a1f8cc

Please sign in to comment.