-
Notifications
You must be signed in to change notification settings - Fork 23
/
terminal_cryptodeeptech.py
83 lines (74 loc) · 2.5 KB
/
terminal_cryptodeeptech.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# -*- coding: utf-8 -*-
"""Terminal_CryptoDeepTech.ipynb
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/1yz-XElYJrW9qoc0Oj1Vy7iDhzCoKWWOs
"""
from google.colab import drive
drive.mount('/content/drive/')
cd drive/MyDrive/
# Commented out IPython magic to ensure Python compatibility.
# #@title JS Shell
# %%html
# <div id=term_demo></div>
# <script src="https://code.jquery.com/jquery-latest.js"></script>
# <script src="https://cdn.jsdelivr.net/npm/jquery.terminal/js/jquery.terminal.min.js"></script>
# <link href="https://cdn.jsdelivr.net/npm/jquery.terminal/css/jquery.terminal.min.css" rel="stylesheet"/>
# <script>
# $('#term_demo').terminal(function(command) {
# if (command !== '') {
# try {
# var result = window.eval(command);
# if (result !== undefined) {
# this.echo(new String(result));
# }
# } catch(e) {
# this.error(new String(e));
# }
# } else {
# this.echo('');
# }
# }, {
# greetings: 'Welcome to JavaScript Shell',
# name: 'js_demo',
# height: 200,
# prompt: 'js> '
# });
#@title IPython.display
from IPython.display import JSON
from google.colab import output
from subprocess import getoutput
import os
def shell(command):
if command.startswith('cd'):
path = command.strip().split(maxsplit=1)[1]
os.chdir(path)
return JSON([''])
return JSON([getoutput(command)])
output.register_callback('shell', shell)
# Commented out IPython magic to ensure Python compatibility.
# #@title Terminal CryptoDeepTech
# %%html
# <div id=term_demo></div>
# <script src="https://code.jquery.com/jquery-latest.js"></script>
# <script src="https://cdn.jsdelivr.net/npm/jquery.terminal/js/jquery.terminal.min.js"></script>
# <link href="https://cdn.jsdelivr.net/npm/jquery.terminal/css/jquery.terminal.min.css" rel="stylesheet"/>
# <script>
# $('#term_demo').terminal(async function(command) {
# if (command !== '') {
# try {
# let res = await google.colab.kernel.invokeFunction('shell', [command])
# let out = res.data['application/json'][0]
# this.echo(new String(out))
# } catch(e) {
# this.error(new String(e));
# }
# } else {
# this.echo('');
# }
# }, {
# greetings: 'Terminal CryptoDeepTech',
# name: 'colab_demo',
# height: 320,
# prompt: 'crypto > '
# });