Skip to content

Commit e68b30e

Browse files
committed
packaging: use WebDemo as the package basename and date as the version. also considerably simpler implementation.
Signed-off-by: Pekka Klärck <peke@iki.fi>
1 parent a8978ef commit e68b30e

File tree

1 file changed

+19
-38
lines changed

1 file changed

+19
-38
lines changed

package.py

Lines changed: 19 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,24 @@
11
#!/usr/bin/env python
22

3-
import os, shutil
3+
from glob import glob
4+
from os import chdir, sep as SEP
5+
from os.path import abspath, dirname, join
6+
from time import localtime
47
from zipfile import ZipFile, ZIP_DEFLATED
58

6-
VERSION = "1.0"
7-
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
8-
#execfile(os.path.join(THIS_DIR, '..', 'src', 'Selenium2Library', 'version.py'))
9+
NAME = 'WebDemo'
10+
ZIP_NAME = NAME + '-%d%02d%02d.zip' % localtime()[:3]
11+
FILES = ['README.rst',
12+
'demoapp/server.py',
13+
'demoapp/html/*.html',
14+
'demoapp/html/*.css',
15+
'login_tests/*.txt']
916

10-
FILES = {
11-
'': ['rundemo.py'],
12-
'testcases': ['valid_login.txt', 'invalid_login.txt','content_check.txt','resource.txt'],
13-
'demoapp': ['server.py'],
14-
'demoapp/html': ['index.html', 'welcome.html', 'error.html', 'demo.css', 'file_information.txt', 'file_names.txt', 'file_places.txt']
15-
}
16-
17-
def main():
18-
cwd = os.getcwd()
19-
try:
20-
os.chdir(THIS_DIR)
21-
name = 'robotframework-selenium2library-%s-demo' % VERSION
22-
zipname = '%s.zip' % name
23-
if os.path.exists(zipname):
24-
os.remove(zipname)
25-
zipfile = ZipFile(zipname, 'w', ZIP_DEFLATED)
26-
for dirname in FILES:
27-
for filename in FILES[dirname]:
28-
path = os.path.join('.', dirname.replace('/', os.sep), filename)
29-
print 'Adding: ', os.path.normpath(path)
30-
zipfile.write(path, os.path.join(name, path))
31-
zipfile.close()
32-
target_path = os.path.join('.', 'dist')
33-
if os.path.exists(target_path):
34-
shutil.rmtree(target_path, ignore_errors=True)
35-
os.makedirs(target_path)
36-
os.rename(zipname, os.path.join(target_path, zipname))
37-
print 'Created: ', os.path.abspath(target_path)
38-
finally:
39-
os.chdir(cwd)
40-
41-
42-
if __name__ == '__main__':
43-
main()
17+
chdir(dirname(abspath(__file__)))
18+
zipfile = ZipFile(ZIP_NAME, 'w', ZIP_DEFLATED)
19+
for pattern in FILES:
20+
for path in glob(pattern.replace('/', SEP)):
21+
print 'Adding: ', path
22+
zipfile.write(path, join(NAME, path))
23+
zipfile.close()
24+
print 'Created: ', ZIP_NAME

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy