forked from cuthbertLab/music21
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupload.py
85 lines (74 loc) · 3.05 KB
/
upload.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
83
84
85
# -*- coding: utf-8 -*-
# ------------------------------------------------------------------------------
# Name: upload.py
# Purpose: music21 documentation upload utility
#
# Authors: Christopher Ariza
#
# Copyright: Copyright © 2009-2010, 2013 Michael Scott Asato Cuthbert
# License: BSD, see license.txt
# ------------------------------------------------------------------------------
# pylint: disable=line-too-long
'''
if you get a 'ssh_askpass' not found error, create this file in
/usr/libexec/ssh-askpass and sudo chmod +x it afterwards:
..raw::
#!/bin/bash
# Script: ssh-askpass
# Author: Mark Carver
# Created: 2011-09-14
# Copyright (c) 2011 Beyond Eden Development, LLC. All rights reserved.
# A ssh-askpass command for Mac OS X
# Based from author: Joseph Mocker, Sun Microsystems
# http://blogs.oracle.com/mock/entry/and_now_chicken_of_the
# To use this script:
# Install this script running INSTALL as root
#
# If you plan on manually installing this script, please note that you will have
# to set the following variable for SSH to recognize where the script is located:
# export SSH_ASKPASS="/path/to/ssh-askpass"
TITLE="${SSH_ASKPASS_TITLE:-SSH}";
TEXT="$(whoami)'s password:";
IFS=$(printf "\n");
CODE=("on GetCurrentApp()");
CODE=(${CODE[*]} "tell application \"System Events\" to get short name of first process whose frontmost is true");
CODE=(${CODE[*]} "end GetCurrentApp");
CODE=(${CODE[*]} "tell application GetCurrentApp()");
CODE=(${CODE[*]} "activate");
CODE=(${CODE[*]} "display dialog \"${@:-$TEXT}\" default answer \"\" with title \"${TITLE}\" with icon caution with hidden answer");
CODE=(${CODE[*]} "text returned of result");
CODE=(${CODE[*]} "end tell");
SCRIPT="/usr/bin/osascript"
for LINE in ${CODE[*]}; do
SCRIPT="${SCRIPT} -e $(printf "%q" "${LINE}")";
done;
eval "${SCRIPT}";
Otherwise just contact MSAC.
'''
from __future__ import annotations
import getpass
import os
def getDirBuildHtml():
'''
Return the html directory
'''
from music21 import common
parentDir = common.getRootFilePath()
dirBuild = os.path.join(parentDir, 'documentation', 'build')
dirBuildHtml = os.path.join(dirBuild, 'html')
return dirBuildHtml
# noinspection SpellCheckingInspection
def main():
# this needs to be on level higher then the level of the source
# DST_MIT = 'athena.dialup.mit.edu:/afs/athena.mit.edu/org/m/music21/doc/'
remoteHost = 'athena.dialup.mit.edu'
remoteDir = '/afs/athena.mit.edu/org/m/music21/doc/'
# tar czpf - -C build/html/ . | ssh [email protected] "tar xzpf - -C /afs/athena.mit.edu/org/m/music21/doc/"
user = getpass.getpass('provide user name : ')
src = getDirBuildHtml()
# -r flag makes this recursive
# noinspection SpellCheckingInspection
cmdStr = f'tar czpf - -C {src} . | ssh {user}@{remoteHost} "tar xzpf - -C {remoteDir}"'
# cmdStr = 'scp -r "%s" %s@%s' % (src + "/*", user, DST_MIT)
print(cmdStr)
os.system(cmdStr)