• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2#
3# Copyright (C) 2020-2021 Huawei Device Co., Ltd.
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#     http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16
17set -e
18
19error()
20{
21  echo "$1"
22  exit 1
23}
24PYTHON="python3"
25TOOLS="tools"
26
27flag=$(command -v $PYTHON | grep -c $PYTHON)
28if [ "$flag" -eq 0 ]; then
29    error "Python3.7 or higher version required!"
30fi
31
32$PYTHON -c 'import sys; exit(1) if sys.version_info.major < 3 or sys.version_info.minor < 7 else exit(0)' || \
33error "Python3.7 or higher version required!"
34cd $(dirname "$0") || error "Failure to change directory!"
35$PYTHON -c "import easy_install" || error "Please install setuptools first!"
36
37if [ ! -d "$TOOLS" ]; then
38  error "$TOOLS directory not exists"
39fi
40
41for f in "$TOOLS"/*.egg
42do
43  if [ ! -e "$f" ]; then
44    error "Can not find xdevice package!"
45  fi
46  $PYTHON -m easy_install --user "$f" || echo "Error occurs to install $f!"
47done
48
49for f in "$TOOLS"/*.tar.gz
50do
51  if [ ! -e "$f" ]; then
52    error "Can not find xdevice package!"
53  fi
54  $PYTHON -m easy_install --user "$f" || echo "Error occurs to install $f!"
55done
56
57$PYTHON -m xdevice "$@"
58exit 0
59