Skip to content
This repository has been archived by the owner on May 16, 2024. It is now read-only.

Commit

Permalink
Merge 7d8e077 into c1b733b
Browse files Browse the repository at this point in the history
  • Loading branch information
sbidoul committed Jun 15, 2018
2 parents c1b733b + 7d8e077 commit 48d1a6b
Show file tree
Hide file tree
Showing 9 changed files with 143 additions and 814 deletions.
26 changes: 6 additions & 20 deletions sample_files/.travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ addons:

env:
global:
- VERSION="10.0" TESTS="0" LINT_CHECK="0" TRANSIFEX="0"
- VERSION="10.0" TESTS="0" LINT_CHECK="0" MAKEPOT="0"
# Set this variable to some version existing as linux-generic build on
# https://github.com/wkhtmltopdf/wkhtmltopdf/releases
# if you need to install wkhtmltopdf
Expand All @@ -46,28 +46,14 @@ env:
# Use the above line to install dependencies that are required for website repos:
# * SASS & Bootstrap-SASS
# * Compass
- TRANSIFEX_USER='transbot@odoo-community.org'
# This line contains the encrypted transifex password
# To encrypt transifex password, install travis ruby utils with:
# $ gem install travis --user-install
# and use:
# $ travis encrypt TRANSIFEX_PASSWORD=your-password -r owner/project
# Secure list for current OCA projects is in https://github.com/OCA/maintainer-quality-tools/issues/194
- secure: PjP88tPSwimBv4tsgn3UcQAD1heK/wcuSaSfhi2xUt/jSrOaTmWzjaW2gH/eKM1ilxPXwlPGyAIShJ2JJdBiA97hQufOeiqxdkWDctnNVVEDx2Tk0BiG3PPYyhXPgUZ+FNOnjZFF3pNWvzXTQaB0Nvz8plqp93Ov/DEyhrCxHDs=
# Use the following lines if you need to manually change the transifex project slug or/and the transifex organization.
# The default project slug is owner-repo_name-version (with dash in the version string).
# The default organization is the owner of the repo.
# The default fill up resources (TM) is True.
# The default team is 23907. https://www.transifex.com/organization/oca/team/23907/
# - TRANSIFEX_PROJECT_SLUG=
# - TRANSIFEX_ORGANIZATION=
# - TRANSIFEX_FILL_UP_RESOURCES=
# - TRANSIFEX_TEAM=

matrix:
- LINT_CHECK="1"
- TRANSIFEX="1"
- TESTS="1" ODOO_REPO="odoo/odoo"
# use this to install a standalone database to export .pot files
# - MAKEPOT="1"
# add MAKEPOT="1" to a TEST line to export .pot files from
# the test database after test success
- TESTS="1" ODOO_REPO="odoo/odoo" MAKEPOT="1"
- TESTS="1" ODOO_REPO="OCA/OCB"
# either use the two lines above or the two below. Don't change the default if
# it's not necessary (it is only necessary if modules in your repository can't
Expand Down
4 changes: 0 additions & 4 deletions sample_files/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ ${REPO_DESCRIPTION}
This part will be replaced when running the oca-gen-addons-table script from OCA/maintainer-tools.
[//]: # (end addons)

Translation Status
------------------
[![Transifex Status](https://www.transifex.com/projects/p/${ORG_NAME}-${REPO_NAME}-${BRANCH_NAME_WITH_DASH}/chart/image_png)](https://www.transifex.com/projects/p/${ORG_NAME}-${REPO_NAME}-${BRANCH_NAME_WITH_DASH})

----

OCA, or the [Odoo Community Association](http://odoo-community.org/), is a nonprofit organization whose
Expand Down
124 changes: 0 additions & 124 deletions travis/apis.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@

import base64
import os
import re
import subprocess
import tempfile
import time
import json
from contextlib import contextmanager
import requests


Expand Down Expand Up @@ -44,125 +39,6 @@ def _request(self, url, payload=None, is_json=True, patch=False):
return response.json() if is_json else response


class WeblateApi(Request):

def __init__(self):
super(WeblateApi, self).__init__()
self.repo_slug = None
self.branch = None
self._token = os.environ.get("WEBLATE_TOKEN")
self.host = os.environ.get(
"WEBLATE_HOST", "https://weblate.odoo-community.org/api")
self.ssh = os.environ.get(
"WEBLATE_SSH", "ssh://user@webpage.com")
self.tempdir = os.path.join(tempfile.gettempdir(), 'weblate_api')
self._ssh_keyscan()

def _ssh_keyscan(self):
"""This method execute the command 'ssh-keysan' to avoid the
question when the command git clone is excecuted.
The question is like to:
'Are you sure you want to continue connecting (yes/no)?'"""
cmd = ['ssh-keyscan', '-p']
match = re.search(
r'(ssh\:\/\/\w+@(?P<host>[a-zA-Z0-9_.-]+))(:{0,1})'
r'(?P<port>(\d+))?', self.ssh)
if not match:
return False
data = match.groupdict()
cmd.append(data['port'] or '22')
cmd.append(data['host'])
with open(os.path.expanduser('~/.ssh/known_hosts'), 'a+') as hosts:
subprocess.Popen(cmd, stdout=hosts)

def get_project(self, repo_slug, branch):
self.branch = branch
projects = []
page = 1
while True:
data = self._request(self.host + '/projects/?page=%s' % page)
projects.extend(data['results'] or [])
if not data['next']:
break
page += 1
for project in projects:
if project['name'] == repo_slug:
self.repo_slug = project['slug']
return project
raise ApiException('No project found in "%s" for this path "%s"' %
(self.host, repo_slug))

def load_project(self, repo_slug, branch):
self.project = self.get_project(repo_slug, branch)
self.load_components()

def get_components(self):
components = []
values = []
page = 1
while True:
data = self._request(self.host +
'/projects/%s/components/?page=%s' %
(self.project['slug'], page))
values.extend(data['results'] or [])
if not data['next']:
break
page += 1
for value in values:
if value['branch'] and value['branch'] != self.branch:
continue
components.append(value)
return components

def load_components(self):
self.components = self.get_components()

def pull(self):
pull = self._request(
self.host + '/projects/%s/repository/' % self.project['slug'],
{'operation': 'pull'})
return pull['result']

def component_repository(self, component, operation):
result = self._request(self.host + '/components/%s/%s/repository/' %
(self.project['slug'], component['slug']),
{'operation': operation})
return result['result']

@contextmanager
def component_lock(self):
try:
for component in self.components:
self._component_lock(component)
self._component_commit(component)
yield
finally:
for component in self.components:
self._component_lock(component, lock=False)

def _component_lock(self, component, lock=True):
url = (self.host + '/components/%s/%s/lock/' %
(self.project['slug'], component['slug']))
for i in range(10):
new_lock = self._request(url, {'lock': lock})
if new_lock['locked'] == lock:
break
time.sleep(60)
return True

def _component_commit(self, component):
url = (self.host + '/components/%s/%s/repository/' %
(self.project['slug'], component['slug']))
needs_commit = self._request(url)
if not needs_commit['needs_commit']:
return
new_commit = self._request(url, {'operation': 'commit'})
if not new_commit['result']:
raise ApiException('The commit into the component "%s" cannot be '
'made' % component['slug'])
return True


class GitHubApi(Request):

def __init__(self):
Expand Down
192 changes: 0 additions & 192 deletions travis/odoo_connection.py

This file was deleted.

0 comments on commit 48d1a6b

Please sign in to comment.