From: "Anthony G. Basile" <blueness@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/grss:master commit in: grs/
Date: Sat, 10 Oct 2015 00:29:53 +0000 (UTC) [thread overview]
Message-ID: <1444437315.438583d1e40fd764d491974d1b0ebd75cacf2148.blueness@gentoo> (raw)
commit: 438583d1e40fd764d491974d1b0ebd75cacf2148
Author: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
AuthorDate: Sat Oct 10 00:35:08 2015 +0000
Commit: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
CommitDate: Sat Oct 10 00:35:15 2015 +0000
URL: https://gitweb.gentoo.org/proj/grss.git/commit/?id=438583d1
grs/Interpret.py: restructure semantic actions.
grs/Interpret.py | 106 ++++++++++++++++++++++---------------------------------
1 file changed, 42 insertions(+), 64 deletions(-)
diff --git a/grs/Interpret.py b/grs/Interpret.py
index 7add215..15b6cfa 100644
--- a/grs/Interpret.py
+++ b/grs/Interpret.py
@@ -79,20 +79,27 @@ class Interpret(Daemon):
sys.exit(signum + 128)
- def smartlog(_log, obj, has_obj):
- """ This logs whether or not we have a grammatically incorrect
- directive, or we are doing a mock run, and returns whether
- or not we should execute the directive:
- True = skip this directive
- False = don't skip it
- """
- if (has_obj and not obj) or (not has_obj and obj):
- _lo.log('Bad command: %s' % _log)
- return True
+ def signalexit():
+ pid = os.getpid()
+ while True:
+ os.kill(pid, signal.SIGTERM)
+ time.sleep(2.0)
+
+
+ def semantic_action(_line, objs, n, execstr):
+ """ Execute the directive """
if self.mock_run:
- _lo.log(_log)
- return True
- return False
+ _lo.log(_line)
+ return
+ try:
+ if len(objs) < n:
+ raise Exception('Number of objs for verb incorrect.')
+ exec(execstr)
+ except Exception as e:
+ _lo.log('Bad command: %s' % _line)
+ _lo.log('Exception throw: %s' % e)
+ _lo.log('SENDING SIGTERM to pid = %d\n' % pid)
+ signalexit()
def stampit(progress):
@@ -195,82 +202,53 @@ class Interpret(Daemon):
sentence = _line.split()
verb = sentence[0]
objs = sentence[1:]
- obj = objs[0]
# This long concatenated if is where the semantics of the
# build script are implemented. Note: 'hashit' can only come
# after 'tarit' or 'isoit' so that it knows the medium_name
# to hash, ie whether its a .tar.xz or a .iso
if verb == 'log':
- if smartlog(_line, obj, True):
- stampit(progress)
- continue
- if obj == 'stamp':
- _lo.log('='*80)
- else:
- _lo.log(obj)
+ if objs[0] == 'stamp':
+ objs[0] = '='*80
+ semantic_action(_line, objs, 1, '_lo.log(\' \'.join(objs))')
elif verb == 'mount':
- if smartlog(_line, obj, False):
- stampit(progress)
- continue
- _md.mount_all()
+ semantic_action(_line, objs, 0, '_md.mount_all()')
elif verb == 'unmount':
- if smartlog(_line, obj, False):
- stampit(progress)
- continue
- _md.umount_all()
+ semantic_action(_line, objs, 0, '_md.umount_all()')
elif verb == 'populate':
- if smartlog(_line, obj, True):
- stampit(progress)
- continue
- _po.populate(cycle=int(obj))
+ semantic_action(_line, objs, 1, '_po.populate(cycle=int(objs[0]))')
elif verb == 'runscript':
- if smartlog(_line, obj, True):
- stampit(progress)
- continue
- _ru.runscript(obj)
+ semantic_action(_line, objs, 1, '_ru.runscript(objs[0])')
elif verb == 'pivot':
- if smartlog(_line, obj, True):
- stampit(progress)
- continue
- _pc.pivot(obj, _md)
+ semantic_action(_line, objs, 1, '_pc.pivot(objs[0], _md)')
elif verb == 'kernel':
- if smartlog(_line, obj, False):
- stampit(progress)
- continue
- _ke.kernel()
+ semantic_action(_line, objs, 0, '_ke.kernel()')
elif verb == 'tarit':
- # 'tarit' can either be just a verb,
- # or a 'verb obj' pair.
- if obj:
- smartlog(_line, obj, True)
- _bi.tarit(obj)
+ # 'tarit' can either be just a verb, or a 'verb obj' pair.
+ if len(objs):
+ semantic_action(_line, objs, 1, '_bi.tarit(objs[0])')
else:
- smartlog(_line, obj, False)
- _bi.tarit()
+ semantic_action(_line, objs, 0, '_bi.tarit()')
medium_type = 'tarit'
elif verb == 'isoit':
- # 'isoit' can either be just a verb,
- # or a 'verb obj' pair.
- if obj:
- smartlog(_line, obj, True)
- _io.isoit(obj)
+ # 'isoit' can either be just a verb, or a 'verb obj' pair.
+ if len(objs):
+ semantic_action(_line, objs, 1, '_io.isoit(objs[1])')
else:
- smartlog(_line, obj, False)
- _io.isoit()
+ semantic_action(_line, objs, 0, '_io.isoit()')
medium_type = 'isoit'
elif verb == 'hashit':
- if smartlog(_line, obj, False):
- stampit(progress)
- continue
if medium_type == 'tarit':
- _bi.hashit()
+ semantic_action(_line, objs, 0, '_bi.hashit()')
elif medium_type == 'isoit':
- _io.hashit()
+ semantic_action(_line, objs, 0, '_io.hashit()')
else:
raise Exception('Unknown medium to hash.')
else:
_lo.log('Bad command: %s' % _line)
+ _lo.log('Unknown verb: %s' % verb)
+ _lo.log('SENDING SIGTERM to pid = %d\n' % pid)
+ signalexit()
stampit(progress)
next reply other threads:[~2015-10-10 0:29 UTC|newest]
Thread overview: 139+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-10 0:29 Anthony G. Basile [this message]
-- strict thread matches above, loose matches on Subject: below --
2022-07-20 2:22 [gentoo-commits] proj/grss:master commit in: grs/ Anthony G. Basile
2022-07-20 1:49 Anthony G. Basile
2022-07-19 20:22 Anthony G. Basile
2022-07-19 20:18 Anthony G. Basile
2022-07-18 21:13 Anthony G. Basile
2019-04-19 12:29 Anthony G. Basile
2018-11-18 19:09 Anthony G. Basile
2018-11-12 3:08 Anthony G. Basile
2018-11-11 23:57 Anthony G. Basile
2018-11-11 23:35 Anthony G. Basile
2018-11-11 23:16 Anthony G. Basile
2018-06-25 20:32 Anthony G. Basile
2018-04-14 14:53 Anthony G. Basile
2018-04-10 3:14 Anthony G. Basile
2018-02-20 2:27 Anthony G. Basile
2018-02-20 2:04 Anthony G. Basile
2018-02-18 22:38 Anthony G. Basile
2018-02-18 16:37 Anthony G. Basile
2018-02-06 11:57 Anthony G. Basile
2018-02-06 11:42 Anthony G. Basile
2018-02-06 11:33 Anthony G. Basile
2018-02-06 10:55 Anthony G. Basile
2018-01-28 12:31 Anthony G. Basile
2018-01-28 12:09 Anthony G. Basile
2018-01-15 1:31 Anthony G. Basile
2018-01-15 1:23 Anthony G. Basile
2018-01-14 18:22 Anthony G. Basile
2018-01-14 17:05 Anthony G. Basile
2018-01-14 15:02 Anthony G. Basile
2018-01-14 14:37 Anthony G. Basile
2018-01-14 14:07 Anthony G. Basile
2018-01-13 17:40 Anthony G. Basile
2018-01-10 21:02 Anthony G. Basile
2018-01-10 20:40 Anthony G. Basile
2017-12-28 17:54 Anthony G. Basile
2017-12-28 17:22 Anthony G. Basile
2017-12-27 9:25 Anthony G. Basile
2017-12-26 14:19 Anthony G. Basile
2017-12-26 0:04 Anthony G. Basile
2017-12-26 0:04 Anthony G. Basile
2017-12-26 0:04 Anthony G. Basile
2017-12-25 23:38 Anthony G. Basile
2017-12-25 23:24 Anthony G. Basile
2017-12-23 16:04 Anthony G. Basile
2017-12-23 14:15 Anthony G. Basile
2016-03-23 15:08 Anthony G. Basile
2016-03-23 15:05 Anthony G. Basile
2015-11-26 19:48 Anthony G. Basile
2015-10-10 20:20 Anthony G. Basile
2015-10-10 19:36 Anthony G. Basile
2015-10-10 19:07 Anthony G. Basile
2015-10-10 12:22 Anthony G. Basile
2015-10-10 11:44 Anthony G. Basile
2015-10-10 11:22 Anthony G. Basile
2015-10-10 11:20 Anthony G. Basile
2015-10-10 11:10 Anthony G. Basile
2015-10-10 1:46 Anthony G. Basile
2015-10-10 1:40 Anthony G. Basile
2015-10-10 1:34 Anthony G. Basile
2015-10-10 1:26 Anthony G. Basile
2015-10-10 1:23 Anthony G. Basile
2015-10-10 1:18 Anthony G. Basile
2015-10-10 0:34 Anthony G. Basile
2015-10-09 23:33 Anthony G. Basile
2015-10-09 23:33 Anthony G. Basile
2015-10-09 23:30 Anthony G. Basile
2015-10-09 23:11 Anthony G. Basile
2015-10-09 23:06 Anthony G. Basile
2015-10-08 23:52 Anthony G. Basile
2015-10-08 18:03 Anthony G. Basile
2015-10-08 17:20 Anthony G. Basile
2015-10-07 11:28 Anthony G. Basile
2015-10-07 11:15 Anthony G. Basile
2015-10-07 11:07 Anthony G. Basile
2015-10-07 11:03 Anthony G. Basile
2015-10-07 10:57 Anthony G. Basile
2015-10-07 8:31 Anthony G. Basile
2015-10-07 8:01 Anthony G. Basile
2015-10-06 10:07 Anthony G. Basile
2015-09-16 22:08 Anthony G. Basile
2015-09-16 5:16 Anthony G. Basile
2015-09-16 0:37 Anthony G. Basile
2015-09-16 0:32 Anthony G. Basile
2015-09-14 7:17 Anthony G. Basile
2015-09-14 5:32 Anthony G. Basile
2015-09-14 5:25 Anthony G. Basile
2015-09-14 0:29 Anthony G. Basile
2015-09-13 17:31 Anthony G. Basile
2015-09-12 20:56 Anthony G. Basile
2015-09-12 20:56 Anthony G. Basile
2015-08-09 20:26 Anthony G. Basile
2015-08-08 20:06 Anthony G. Basile
2015-08-08 18:01 Anthony G. Basile
2015-08-08 17:51 Anthony G. Basile
2015-07-29 0:20 Anthony G. Basile
2015-07-28 22:44 Anthony G. Basile
2015-07-27 20:49 Anthony G. Basile
2015-07-25 22:36 Anthony G. Basile
2015-07-14 23:37 Anthony G. Basile
2015-07-14 23:29 Anthony G. Basile
2015-07-14 23:19 Anthony G. Basile
2015-07-14 23:16 Anthony G. Basile
2015-07-14 23:02 Anthony G. Basile
2015-07-14 22:39 Anthony G. Basile
2015-07-14 22:35 Anthony G. Basile
2015-07-14 21:45 Anthony G. Basile
2015-07-14 21:21 Anthony G. Basile
2015-07-14 21:02 Anthony G. Basile
2015-07-14 20:55 Anthony G. Basile
2015-07-10 12:54 Anthony G. Basile
2015-07-10 2:37 Anthony G. Basile
2015-07-10 2:37 Anthony G. Basile
2015-07-10 2:01 Anthony G. Basile
2015-07-09 15:26 Anthony G. Basile
2015-07-09 1:44 Anthony G. Basile
2015-07-08 15:44 Anthony G. Basile
2015-07-08 10:28 Anthony G. Basile
2015-07-07 20:52 Anthony G. Basile
2015-07-07 20:34 Anthony G. Basile
2015-07-07 14:30 Anthony G. Basile
2015-07-07 12:54 Anthony G. Basile
2015-07-07 12:46 Anthony G. Basile
2015-07-07 12:44 Anthony G. Basile
2015-07-07 12:33 Anthony G. Basile
2015-07-07 11:26 Anthony G. Basile
2015-07-07 2:17 Anthony G. Basile
2015-07-06 20:13 Anthony G. Basile
2015-07-06 18:13 Anthony G. Basile
2015-07-05 16:49 Anthony G. Basile
2015-07-05 12:04 Anthony G. Basile
2015-07-02 22:30 Anthony G. Basile
2015-07-01 17:27 Anthony G. Basile
2015-07-01 17:03 Anthony G. Basile
2015-07-01 16:53 Anthony G. Basile
2015-07-01 16:52 Anthony G. Basile
2015-07-01 16:07 Anthony G. Basile
2015-07-01 12:30 Anthony G. Basile
2015-07-01 12:23 Anthony G. Basile
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1444437315.438583d1e40fd764d491974d1b0ebd75cacf2148.blueness@gentoo \
--to=blueness@gentoo.org \
--cc=gentoo-commits@lists.gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox