Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
rdteam
python-examples
Commits
5bb1eccb
Commit
5bb1eccb
authored
May 06, 2015
by
Bstrdsmkr
Browse files
Update code for the new format
parent
a13c13ad
Changes
3
Hide whitespace changes
Inline
Side-by-side
basic_bottle_template.py
deleted
100644 → 0
View file @
a13c13ad
from
bottle
import
Bottle
,
request
,
run
app
=
Bottle
()
@
app
.
route
(
'/say_hello'
,
method
=
'POST'
)
def
hello
():
name
=
request
.
forms
[
'name'
]
return
"Hello {}!"
.
format
(
name
)
run
(
app
,
host
=
'localhost'
,
port
=
8080
)
challenge2.py
0 → 100644
View file @
5bb1eccb
import
requests
from
threading
import
Thread
from
bottle
import
Bottle
,
request
,
run
app
=
Bottle
()
@
app
.
route
(
'/new_registration'
,
method
=
'POST'
)
def
new_registration
():
nick
=
request
.
forms
[
'nick'
]
print
"{} has joined the channel"
.
format
(
nick
)
@
app
.
route
(
'/new_msg'
,
method
=
'POST'
)
def
new_msg
():
##########################################################
# This will get called every time the server sends you a
# new message
# Get the 'nick' and 'msg' parameters and print out a
# formatted string
##########################################################
def
poll_user_input
(
nick
):
while
True
:
msg
=
raw_input
(
"Send message: "
)
payload
=
{
'msg'
:
msg
,
'nick'
:
nick
}
requests
.
post
(
'http://testpuppet.ornl.gov/chat'
,
data
=
payload
)
##############################################################
# 1. Use your code from Challenge #1 to register to the server
# 2. Set the 'my_nick' variable to the uid you registered with
##############################################################
input_loop
=
Thread
(
target
=
poll_user_input
,
args
=
(
my_nick
,))
input_loop
.
start
()
run
(
app
,
host
=
'localhost'
,
port
=
80
)
fix_vim.py
0 → 100644
View file @
5bb1eccb
import
paramiko
from
getpass
import
getpass
password
=
getpass
(
"Enter password: "
)
names
=
[
"anthony"
,
"brian"
,
"caleb"
,
"dale"
,
"davida"
,
"davids"
,
"janice"
,
"jason"
,
"jim"
,
"john"
,
"ken"
,
"ketan"
,
"matt"
,
"michael"
,
"nathan"
,
"patti"
,
"pete"
,
"rich"
,
"robert"
,
"steve"
,
"zach"
]
ssh
=
paramiko
.
SSHClient
()
ssh
.
set_missing_host_key_policy
(
paramiko
.
AutoAddPolicy
())
vimrc
=
'''
filetype off
call pathogen#infect()
call pathogen#helptags()
" let g:flake8_show_quickfix=0
let g:flake8_show_in_gutter=1
let g:flake8_show_in_file=1
autocmd BufWritePost *.py call Flake8()
map <leader>j :RopeGotoDefinition<CR>
map <leader>r :RopeRename<CR>
nmap <leader>a <Esc>:Ack!
au FileType python set omnifunc=pythoncomplete#Complete
let g:SuperTabDefaultCompletionType = "context"
set completeopt=menuone,longest,preview
let g:indent_guides_enable_on_vim_startup = 1
let g:indent_guides_auto_colors = 0
autocmd VimEnter,Colorscheme * :hi IndentGuidesOdd ctermbg=236
autocmd VimEnter,Colorscheme * :hi IndentGuidesEven ctermbg=240
set foldmethod=indent
set foldlevel=99
set number
set paste
syntax on " syntax highlighting
colorscheme monokai
filetype on " try to detect filetypes
filetype plugin indent on " enable loading indent file for filetype
au VimEnter * RainbowParenthesesToggle
au Syntax * RainbowParenthesesLoadRound
au Syntax * RainbowParenthesesLoadSquare
au Syntax * RainbowParenthesesLoadBraces
'''
for
user
in
names
:
vm_name
=
"{}-cades.ornl.gov"
.
format
(
user
)
print
'Connecting to {}'
.
format
(
vm_name
)
ssh
.
connect
(
vm_name
,
username
=
'root'
,
password
=
password
)
sftp
=
ssh
.
open_sftp
()
with
sftp
.
open
(
"/etc/skel/.vimrc"
,
"w"
)
as
remtote_vimrc
:
remtote_vimrc
.
write
(
vimrc
)
sftp
.
close
()
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment