sync_figures.py 1.92 KB
Newer Older
1
2
3
4
__author__ = 'abuddenberg'

from webform_client import WebformClient
from gcis_client import GcisClient
5
6
import json
from subprocess import call
7
8
9
10
11
12

# webform_dev = ('http://dev.nemac.org/asides10/metadata/figures/all?token=A2PNYxRuG9')

webform = WebformClient('http://resources.assessment.globalchange.gov', 'mgTD63FAjG')

gcis_url = 'http://data.gcis-dev-front.joss.ucar.edu'
13
gcis = GcisClient(gcis_url, 'andrew.buddenberg@noaa.gov', '4cd31dc7173eb47b26f616fb07db607f25ab861552e81195')
14

15
# stage = GcisClient('http://data-stage.globalchange.gov', 'andrew.buddenberg@noaa.gov', 'ef427a895acf26d4f0b1f053ba7d922791b76f7852e7efee')
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
# print gcis.update_figure('nca3draft', 'our-changing-climate', figure, skip_images=True)

# for item in webform.get_list():
#     webform_url = item['url']
#     print webform_url
#     print webform.get_webform(webform_url)


heavy_precip = webform.get_webform('/metadata/figures/2506').merge(
    gcis.get_figure('nca3draft', 'observed-change-in-very-heavy-precipitation', chapter_id='our-changing-climate')
)

# for i in heavy_precip.images[1:]:
#     gcis.create_image(i, report_id='nca3draft', figure_id='observed-change-in-very-heavy-precipitation')

gcis.update_figure('nca3draft', 'our-changing-climate', heavy_precip)

# heavy_precip = webform.get_webform('/metadata/figures/2506')
#
# for i in heavy_precip.images:
#     # print i.as_json()
#     # print i.filepath, webform.image_exists(i.filepath)
#     image = webform.download_image(i.filepath)
#     call(['/opt/local/bin/convert', image, image.replace('.eps', '.png')])



# print json.dumps(webform.get_webform('/metadata/figures/3294').original, indent=4)

# for image in figure.images[1:]:
51
52
53
#     print image.identifier
#     image.filename = file_map[image.identifier]
#
54
55
56
57
58
#     print gcis.associate_image_with_figure(image.identifier, 'nca3draft', figure.identifier)

    # print gcis.create_image(image, report_id='nca3draft', figure_id='temperature-change')