Skip to content

Commit

Permalink
wip renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
jefdaj committed Jan 9, 2020
1 parent 7a393cd commit a857931
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 57 deletions.
36 changes: 18 additions & 18 deletions Docs.cabal
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
name: Docs
synopsis: Partial automation for updating the shortcut-demo docs
synopsis: Partial automation for updating the ortholang-demo docs
author: Jeffrey David Johnson
maintainer: [email protected]
version: 0.1
license: AGPL-3
license-file: LICENSE
build-type: Simple
cabal-version: >=1.10
data-files: shortcut/data/*.fa,
shortcut/data/*.faa,
shortcut/data/*.fna,
shortcut/data/*.gbk,
shortcut/data/*.txt,
shortcut/docs/*.txt,
shortcut/docs/modules/*.txt,
shortcut/docs/types/*.txt,
shortcut/docs/functions/*.txt,
shortcut/tests/check/*.sh,
shortcut/tests/versions/*.txt,
shortcut/tests/repl/*.txt,
shortcut/tests/scripts/*.cut,
shortcut/tests/stdout/*.txt,
shortcut/tests/tmpfiles/*.txt,
shortcut/wrapper-scripts/*.sh
data-files: ortholang/data/*.fa,
ortholang/data/*.faa,
ortholang/data/*.fna,
ortholang/data/*.gbk,
ortholang/data/*.txt,
ortholang/docs/*.txt,
ortholang/docs/modules/*.txt,
ortholang/docs/types/*.txt,
ortholang/docs/functions/*.txt,
ortholang/tests/check/*.sh,
ortholang/tests/versions/*.txt,
ortholang/tests/repl/*.txt,
ortholang/tests/scripts/*.cut,
ortholang/tests/stdout/*.txt,
ortholang/tests/tmpfiles/*.txt,
ortholang/wrapper-scripts/*.sh

executable docs
main-is: Docs.hs
default-language: Haskell2010
hs-source-dirs: .,
shortcut
ortholang
build-depends: OrthoLang,
Glob,
MissingH,
Expand Down
4 changes: 2 additions & 2 deletions Docs.hs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module Main where

{- This isn't meant for end users. It's just an easy way to keep
- the module reference on the website in sync with the actual code.
- Run shortcut --reference to generate an updated templates/reference.md
- Run ortholang --reference to generate an updated templates/reference.md
-
- TODO put in a separate binary?
-}
Expand Down Expand Up @@ -115,7 +115,7 @@ writePlaceholder docsDir name = do
putStrLn path
writeFile path $ "doc for " ++ name ++ " not written yet"

-- TODO take one argument like: shortcut-docs ~/shortcut-demo/templates/reference.md
-- TODO take one argument like: ortholang-docs ~/ortholang-demo/templates/reference.md
main :: IO ()
main = do
writeDocPlaceholders modules
Expand Down
2 changes: 1 addition & 1 deletion common-names.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ cd /mnt/data/PhytozomeV12

# i downloaded the portal pages with a firefox plugin since they require javascript
# this moves them to their proper organism folders
for f in /home/jefdaj/shortcut-demo/portals/*.html; do
for f in /home/jefdaj/ortholang-demo/portals/*.html; do
a=$(grep_alias "$f")
# cp "$f" "${a}/portal.html" || echo "no dir: $a"
d=early_release/$(ls early_release | grep $a)
Expand Down
12 changes: 6 additions & 6 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
let
# fetch my pinned nixpkgs for reproducibility
# (shortcut-linux, dervived from nixpkgs-channels/nixos-19.09)
# (ortholang-linux, dervived from nixpkgs-channels/nixos-19.09)
pkgs = let inherit (import <nixpkgs> {}) stdenv fetchFromGitHub; in import (fetchFromGitHub {
owner = "jefdaj";
repo = "nixpkgs";
Expand All @@ -10,7 +10,7 @@ let
# use this instead to try to build it with your system's current nixpkgs:
# pkgs = import <nixpkgs> {};

shortcut = import ./shortcut;
ortholang = import ./ortholang;
myPython = import ./requirements.nix { inherit pkgs; };

runDepends = [
Expand All @@ -23,13 +23,13 @@ let
myPython.packages."misaka"
myPython.packages."psutil"
myPython.packages."pexpect"
shortcut
ortholang
];

in pkgs.stdenv.mkDerivation rec {
src = ./.;
version = "0.1";
name = "shortcut-demo-${version}";
name = "ortholang-demo-${version}";
inherit runDepends;
buildInputs = [ pkgs.makeWrapper ] ++ runDepends;
builder = pkgs.writeScript "builder.sh" ''
Expand All @@ -38,8 +38,8 @@ in pkgs.stdenv.mkDerivation rec {
mkdir -p $out/src
cp -R $src/templates $src/static $out/src
mkdir -p $out/bin
dest="$out/bin/shortcut-demo"
install -m755 $src/shortcut-demo.py $dest
dest="$out/bin/ortholang-demo"
install -m755 $src/ortholang-demo.py $dest
wrapProgram $dest --prefix PATH : "${pkgs.lib.makeBinPath runDepends}"
'';
}
6 changes: 3 additions & 3 deletions docs.nix
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
with import ./shortcut/nixpkgs;
with import ./ortholang/nixpkgs;

let
shortcut = import ./shortcut/default.nix;
ortholang = import ./ortholang/default.nix;

in haskell.lib.overrideCabal shortcut (drv: {
in haskell.lib.overrideCabal ortholang (drv: {
buildDepends = drv.buildDepends ++ [stack];
shellHook = ''
${drv.shellHook or ""}
Expand Down
2 changes: 1 addition & 1 deletion genomes.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,5 @@ def guess_type(path):
# if 'Hannu' in d:
# print j
js.append(j)
with open('/home/jefdaj/shortcut-demo/templates/genomes.json', 'w') as f:
with open('/home/jefdaj/ortholang-demo/templates/genomes.json', 'w') as f:
f.write(json.dumps(js, indent=2))
20 changes: 10 additions & 10 deletions service.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ with lib;
# TODO don't kill all python processes when stopping

let
cfg = config.services.shortcutDemo;
cfg = config.services.ortholangDemo;
pkgs2 = pkgs // {
# adjust these to your system:
shortcut = import ./shortcut;
"shortcut-demo" = import ./default.nix;
ortholang = import ./ortholang;
"ortholang-demo" = import ./default.nix;
};

in {
options = {
services.shortcutDemo = {
services.ortholangDemo = {
enable = mkOption {
default = false;
type = with types; bool;
Expand All @@ -32,15 +32,15 @@ in {
};

authPath = mkOption {
default = "/tmp/shortcut-users.txt"; # TODO where should this go by default?
default = "/tmp/ortholang-users.txt"; # TODO where should this go by default?
type = with types; uniq string;
description = ''
Path to the auth file (tab-separated usernames and passwords)
'';
};

logPath = mkOption {
default = "/tmp/shortcut-demo.log";
default = "/tmp/ortholang-demo.log";
type = with types; uniq string;
description = ''
Where to write the server log.
Expand All @@ -65,7 +65,7 @@ in {
};

tmpDir = mkOption {
default = "/tmp/shortcut-demo";
default = "/tmp/ortholang-demo";
type = with types; uniq string;
description = ''
Where to save user tmpfiles. Ideally in RAM or at least on an SSD.
Expand Down Expand Up @@ -101,15 +101,15 @@ in {
};

config = mkIf cfg.enable {
systemd.services."shortcut-demo" = {
systemd.services."ortholang-demo" = {
wantedBy = [ "multi-user.target" ];
after = [ "network.target" ];
description = "OrthoLang demo server";
serviceConfig = {
Type = "simple";
User = "${cfg.user}";
ExecStart = ''
${pkgs2.shortcut-demo}/bin/shortcut-demo \
${pkgs2.ortholang-demo}/bin/ortholang-demo \
-l ${cfg.logPath} \
-e ${cfg.examplesDir} \
-c ${cfg.commentsDir} \
Expand All @@ -124,6 +124,6 @@ in {
};
};

environment.systemPackages = [ pkgs2.shortcut pkgs2.procps ];
environment.systemPackages = [ pkgs2.ortholang pkgs2.procps ];
};
}
28 changes: 14 additions & 14 deletions shortcut-demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
Launch the OrthoLang demo server.
Usage:
shortcut-demo (-h | --help)
shortcut-demo -l LOG -e EXAMPLES -c COMMENTS -t TMP -p PORT -a AUTH -u USERS -s SHARED
ortholang-demo (-h | --help)
ortholang-demo -l LOG -e EXAMPLES -c COMMENTS -t TMP -p PORT -a AUTH -u USERS -s SHARED
Options:
-h, --help Show this help text
Expand Down Expand Up @@ -81,7 +81,7 @@
# repl sessions, indexed by sid and also username if logged in
SESSIONS = {}

# prompt arrow, which should match the shortcut code
# prompt arrow, which should match the ortholang code
# ARROW = "❱❱❱ "
# ARROW = "-> " # TODO does it need escaping in regexes?
ARROW = u' —▶ '
Expand All @@ -106,7 +106,7 @@

# set up logging for this module
# note: socketio + engineio loggers are messed with later
LOGGER = LOGGING.getLogger('shortcut')
LOGGER = LOGGING.getLogger('ortholang')
LOGGER.setLevel(LOGGING.DEBUG)
LOGGER.addHandler(HANDLER)
LOGGER.info('starting demo.py')
Expand Down Expand Up @@ -379,7 +379,7 @@ def find_session(sid=None, username=None):
return SESSIONS[sid]

def interpret_clear_code(sessionids, sometext):
# remove terminal escape sequences like "clear screen" in shortcut
# remove terminal escape sequences like "clear screen" in ortholang
# based on https://stackoverflow.com/a/14693789
ansi_clear = re.compile(r'\x1B\[2J')
ansi_escape = re.compile(r'\x1B\[[0-?]*[ -/]*[@-~]')
Expand Down Expand Up @@ -507,22 +507,22 @@ def handle_reqresult():


############
# shortcut #
# ortholang #
############

def check_shortcut_version():
LOGGER.info('checking output of "shortcut --version"')
def check_ortholang_version():
LOGGER.info('checking output of "ortholang --version"')
version_expected = u'OrthoLang 0.9.2'
proc = spawn('shortcut', ['--version'], encoding='utf-8', timeout=None)
proc = spawn('ortholang', ['--version'], encoding='utf-8', timeout=None)
try:
proc.expect(version_expected, timeout=10)
except:
msg = '"shortcut --version" failed. Check your PATH and version.'
msg = '"ortholang --version" failed. Check your PATH and version.'
msg += ' It should be: ' + str(version_expected)
LOGGER.error(msg)
raise SystemExit(1)

check_shortcut_version()
check_ortholang_version()

class OrthoLangThread(Thread):
def __init__(self, sessionid, username):
Expand Down Expand Up @@ -557,7 +557,7 @@ def run(self):
while True:
index = self.process.expect(options)
out = self.process.before + self.process.after
out = interpret_clear_code(self.sessionids, out) # catches shortcut's "clear screen" command
out = interpret_clear_code(self.sessionids, out) # catches ortholang's "clear screen" command
self.emitText(out)
# self.emitText(self.process.before.lstrip())
# self.emitText(self.process.after)
Expand All @@ -570,7 +570,7 @@ def run(self):
continue


# TODO currently this is the same as killing the interpreter... handle separately in shortcut?
# TODO currently this is the same as killing the interpreter... handle separately in ortholang?
def stopEval(self):
# LOGGER.info('session %s stopping %s evaluation' % (self.sessionid, self.process.pid))
LOGGER.info('session %s stopping evaluation' % self.sessionids)
Expand Down Expand Up @@ -610,7 +610,7 @@ def spawnRepl(self):
self.killRepl()
args = ['--secure', '--noprogress', '--interactive', '--tmpdir', self.tmpdir, '--workdir', self.workdir, '--shared', CONFIG['shared_dir']]
# self.process = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=STDOUT, preexec_fn=setsid)
self.process = spawn('shortcut', args, encoding='utf-8', echo=False, timeout=None)
self.process = spawn('ortholang', args, encoding='utf-8', echo=False, timeout=None)
# LOGGER.info('session %s spawned interpreter %s' % (self.sessionid, self.process.pid))
LOGGER.info('session %s spawned interpreter' % self.sessionids)

Expand Down
4 changes: 2 additions & 2 deletions stack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ nix:
extra-package-dbs: []
packages:
- .
- shortcut
- shortcut/logging
- ortholang
- ortholang/logging

# it works best if this matches the haskell.compiler.ghcXXX version in default.nix
system-ghc: true
Expand Down

0 comments on commit a857931

Please sign in to comment.