1. Bruno Villasanti
  2. tryton_get_modules

Commits

Bruno Villasanti  committed c87b63d

Initial commit of Tryton Get Modules

Wizard of download stable modules of Tryton.

  • Participants
  • Branches default

Comments (0)

Files changed (5)

File __init__.py

View file
  • Ignore whitespace
+#This file is part of Tryton.  The COPYRIGHT file at the top level of
+#this repository contains the full copyright notices and license terms.
+
+from get_modules import *

File __tryton__.py

View file
  • Ignore whitespace
+#This file is part of Tryton.  The COPYRIGHT file at the top level of
+#this repository contains the full copyright notices and license terms.
+{
+    'name': 'Tryton Get Modules',
+    'name_es_ES': 'Descarga de módulos de Tryton',
+    'version': '2.2.1',
+    'author': 'Bruno M. Villasanti, Ernesto D. Sequeira',
+    'email': 'bvillasanti@thymbra.com, sequeira.david.ernesto@gmail.com',
+    'website': 'http://www.tryton.org/',
+    'description': '''
+Wizard of download stable modules of Tryton.
+''',
+    'description_es_ES': '''
+Asistente de descarga de módulos estables de Tryton.
+''',
+    'depends': [
+        'res',
+        'ir',
+    ],
+    'xml': [
+        'get_modules.xml',
+    ],
+    'translation': [],
+}

File get_modules.py

View file
  • Ignore whitespace
+#This file is part of Tryton.  The COPYRIGHT file at the top level of
+#this repository contains the full copyright notices and license terms.
+from trytond.model import ModelView, fields
+from trytond.wizard import Wizard
+import urllib2
+import os
+
+
+def _get_version():
+    html = urllib2.urlopen('http://www.tryton.org/downloads.html').read()
+    html_lst = html.split('"')
+    versions = [ x.replace('http://downloads.tryton.org/', '').split('/')[0]
+            for x in html_lst
+            if x[:28] == 'http://downloads.tryton.org/' and x[-1] == '/' ]
+    versions.sort()
+    versions.reverse()
+    res = []
+    for v in versions:
+        res.append((v, 'Version ' + v))
+    return res
+
+_VERSION = _get_version()
+
+
+class GetModulesTryton(ModelView):
+    'Get Modules of Tryton'
+    _name = 'get.modules'
+    _description = __doc__
+
+    version = fields.Selection(_VERSION, 'Version',
+        help='Online available versions')
+
+    def default_version(self):
+        return '2.2'
+
+GetModulesTryton()
+
+
+class GetModulesWizard(Wizard):
+    'Get Modules Wizard'
+    _name = 'get.modules.wizard'
+    _description = __doc__
+
+
+    def _get_modules(self, data):
+        link_str = 'http://downloads.tryton.org/%s/' % data['form']['version']
+        html = urllib2.urlopen(link_str).read()
+        html_lst = html.split('"')
+        files = [ x.replace('trytond_', '').replace('.tar.gz', '')
+                for x in html_lst if x[:8] == 'trytond_' ]
+        modules = [ x.split('-') for x in files ]
+        lst = {}
+        for m in modules:
+            if not m[0] in lst:
+                lst[m[0]] = [m[1]]
+            else:
+                lst[m[0]].append(m[1])
+        links = []
+        for m in lst.keys():
+            lst[m].sort()
+            lst[m].reverse()
+            lst[m] = lst[m][0]
+            links.append('trytond_' + m + '-' + lst[m])
+
+        for ln in links:
+            os.system('wget ' + link_str + ln + '.tar.gz')
+        return {}
+
+    states = {
+        'init': {
+            'actions': [],
+            'result': {
+                'type': 'form',
+                'object': 'get.modules',
+                'state': [
+                    ('end', 'Cancel', 'tryton-cancel'),
+                    ('execute', 'Start', 'tryton-ok', True),
+                ],
+            },
+        },
+        'execute': {
+            'result': {
+                    'type': 'action',
+                    'action': '_get_modules',
+                    'state': 'end',
+            },
+        }
+    }
+
+GetModulesWizard()

File get_modules.xml

View file
  • Ignore whitespace
+<?xml version="1.0"?>
+<!-- This file is part of Tryton.  The COPYRIGHT file at the top level of
+this repository contains the full copyright notices and license terms. -->
+<tryton>
+    <data>
+
+        <record model="ir.ui.icon" id="tryton_modules_icon">
+            <field name="name">tryton-modules</field>
+            <field name="path">icons/tryton-modules.svg</field>
+        </record>
+        <menuitem name="Get Modules" id="menu_get_modules" sequence="10"
+            icons="tryton-modules"/>
+
+         <record model="ir.action.wizard" id="act_wiz_get_modules">
+            <field name="name">Get Modules Wizard</field>
+            <field name="wiz_name">get.modules.wizard</field>
+        </record>
+        <menuitem name="Wizard Get Modules" id="menu_wiz_get_modules"
+            sequence="10" action="act_wiz_get_modules"
+            parent="menu_get_modules" icon="tryton-modules"/>
+
+         <record model="ir.ui.view" id="get_modules_view_form">
+            <field name="model">get.modules</field>
+            <field name="type">form</field>
+            <field name="arch" type="xml">
+                <![CDATA[
+                <form string="Wizard Get Modules">
+                    <notebook colspan="4">
+                        <page string="General" id="page_general_get_version"
+                            col="2">
+                            <label name="version"/>
+                            <field name="version"/>
+                            <newline/>
+                        </page>
+                    </notebook>
+                </form>
+                ]]>
+            </field>
+        </record>
+
+    </data>
+</tryton>

File icons/tryton-modules.svg

View file
  • Ignore whitespace
Added
New image