-
-
Notifications
You must be signed in to change notification settings - Fork 600
/
Copy pathfileserver.py
56 lines (48 loc) · 1.81 KB
/
fileserver.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
# -*- coding: utf-8 -*-
"""
Interface to the Sage fileserver
"""
# ****************************************************************************
# Copyright (C) 2016 Volker Braun <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
# https://www.gnu.org/licenses/
# ****************************************************************************
import os
import subprocess
class FileServer(object):
def __init__(self):
self.user = 'sagemath'
self.hostname = 'fileserver.sagemath.org'
def upstream_directory(self, package):
"""
Return the directory where the tarball resides on the server
"""
return os.path.join(
'/', 'data', 'files', 'spkg', 'upstream', package.name,
)
def upload(self, package):
"""
Upload the current tarball of package
"""
if not package.tarball.is_distributable():
raise ValueError('Tarball of {} is marked as not distributable'.format(package))
subprocess.check_call([
'ssh', '[email protected]',
'mkdir -p {0} && touch {0}/index.html'.format(self.upstream_directory(package))
])
subprocess.check_call([
'rsync', '-av', '--checksum', '-e', 'ssh -l sagemath',
package.tarball.upstream_fqn,
'fileserver.sagemath.org:{0}'.format(self.upstream_directory(package))
])
def publish(self):
"""
Publish the files
"""
subprocess.check_call([
'ssh', '[email protected]', './publish-files.sh'
])