This file is indexed.

/usr/bin/biomaj-cli.py is in python3-biomaj3-cli 3.1.9-1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 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
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
#!/usr/bin/python3
#!/usr/bin/python3
import os
import sys
import argparse
import logging
import getpass
import requests
import datetime
import json

from biomaj_cli.utils import Utils
from biomaj_cli.utils import Options
from biomaj_core.config import BiomajConfig


def main():

    parser = argparse.ArgumentParser(add_help=False)
    Utils.set_args(parser)

    options = Options()
    parser.parse_args(namespace=options)

    options.no_log = False

    if options.help:
        print('''
    --config: global.properties file path (local install only)

    --proxy: BioMAJ daemon url (http://x.y.z)

    --trace: Trace workflow in Zipkin server

    --api-key: User API key to authenticate against proxy

    --whatsup: Get info on what biomaj is doing

    --last-log: Get log file of last session
        [MANDATORY]
        --proxy http://x.y.z
        [OPTIONAL]
        --tail X number of lines to tail from log file

    --about-me: Get my info
        [MANDATORY]
        --proxy http://x.y.z
        --user-login XX
        --user-password XX

    --update-status: get status of an update
        [MANDATORY]
        --bank xx: name of the bank to check
        --proxy http://x.y.z

    --update-cancel: cancel current update
        [MANDATORY]
        --bank xx: name of the bank to cancel
        --proxy http://x.y.z

    --status: list of banks with published release
        [OPTIONAL]
        --bank xx / bank: Get status details of bank

    --status-ko: list of banks in error status (last run)

    --log DEBUG|INFO|WARN|ERR  [OPTIONAL]: set log level in logs for this run, default is set in global.properties file

    --check: Check bank property file
        [MANDATORY]
        --bank xx: name of the bank to check (will check xx.properties)

    --owner yy: Change owner of the bank (user id)
        [MANDATORY]
        --bank xx: name of the bank

    --visibility public|private: change visibility public/private of a bank
        [MANDATORY]
        --bank xx: name of the bank

    --change-dbname yy: Change name of the bank to this new name
        [MANDATORY]
        --bank xx: current name of the bank

    --move-production-directories yy: Change bank production directories location to this new path, path must exists
        [MANDATORY]
        --bank xx: current name of the bank

    --update: Update bank
        [MANDATORY]
        --bank xx: name of the bank(s) to update, comma separated
        [OPTIONAL]
        --publish: after update set as *current* version
        --from-scratch: force a new update cycle, even if release is identical, release will be incremented like (myrel_1)
        --stop-before xx: stop update cycle before the start of step xx
        --stop-after xx: stop update cycle after step xx has completed
        --from-task xx --release yy: Force an re-update cycle for bank release *yy* or from current cycle (in production directories), skipping steps up to *xx*
        --process xx: linked to from-task, optionally specify a block, meta or process name to start from
        --release xx: release to update

    --publish: Publish bank as current release to use
        [MANDATORY]
        --bank xx: name of the bank to update
        --release xx: release of the bank to publish

    --unpublish: Unpublish bank (remove current)
        [MANDATORY]
        --bank xx: name of the bank to update

    --remove-all: Remove all bank releases and database records
        [MANDATORY]
        --bank xx: name of the bank to update
        [OPTIONAL]
        --force: remove freezed releases

    --remove-pending: Remove pending releases
        [MANDATORY]
        --bank xx: name of the bank to update

    --remove: Remove bank release (files and database release)
        [MANDATORY]
        --bank xx: name of the bank to update
        --release xx: release of the bank to remove

        Release must not be the *current* version. If this is the case, publish a new release before.

    --freeze: Freeze bank release (cannot be removed)
        [MANDATORY]
        --bank xx: name of the bank to update
        --release xx: release of the bank to remove

    --unfreeze: Unfreeze bank release (can be removed)
        [MANDATORY]
        --bank xx: name of the bank to update
        --release xx: release of the bank to remove

    --search: basic search in bank production releases, return list of banks
       --formats xx,yy : list of comma separated format
      AND/OR
       --types xx,yy : list of comma separated type

       --query "LUCENE query syntax": search in index (if activated)

    --show: Show bank files per format
      [MANDATORY]
      --bank xx: name of the bank to show
      [OPTIONAL]
      --release xx: release of the bank to show

    --maintenance on/off/status: (un)set biomaj in maintenance mode to prevent updates/removal

    --schedule: Get bank scheduling (needs biomaj-release)
        [MANDATORY]
        --proxy http://x.y.z

    --stats: Get statistics

    --json: Get output in JSON format
        ''')

        return

    proxy = options.proxy

    if 'BIOMAJ_PROXY' in os.environ:
        proxy = os.environ['BIOMAJ_PROXY']
        options.proxy = proxy

    if 'BIOMAJ_APIKEY' in os.environ:
        apikey = os.environ['BIOMAJ_APIKEY']
        options.apikey = apikey

    if len(sys.argv)==1:
        parser.print_help()
        sys.exit(1)

    if not proxy:
        try:
            from biomaj_daemon.daemon.utils import biomaj_client_action
        except Exception as e:
            print('Failed to import biomaj libraries. Either you forgot the --proxy option, either you use a local biomaj install and did not installed it (biomaj-daemon package)')

    try:
        if not proxy:
            from biomaj_daemon.daemon.utils import biomaj_client_action
            options.user = getpass.getuser()
            BiomajConfig.load_config(options.config)
            status = False
            msg = None
            try:
                (status, msg) = biomaj_client_action(options)
            except Exception as e:
                status = False
                msg = str(e)
        else:
            headers = {}
            if options.apikey:
                headers = {'Authorization': 'APIKEY ' + options.apikey}

            if options.schedule:
                r = requests.get(proxy + '/api/release/schedule', headers=headers)
                if not r.status_code == 200:
                    print('Failed to contact schedule service')
                    sys.exit(1)
                schedule = r.json()
                for bank in schedule['schedule']:
                    sched_next = 'not planned'
                    if bank['next'] is not None:
                        sched_next = datetime.datetime.fromtimestamp(bank['next'])
                    print(bank['name'] + ': ' + str(sched_next))
                sys.exit(0)

            if options.lastlog:
                if not options.bank:
                    print("--bank is missing\n")
                    sys.exit(1)
                if options.tail:
                    r = requests.get(proxy + '/api/daemon/bank/' + options.bank + '/log/' + options.tail, headers=headers)
                    print(r.text)
                else:
                    r = requests.get(proxy + '/api/daemon/bank/' + options.bank + '/log', headers=headers)
                    print(r.text)
                sys.exit(0)

            r = requests.post(proxy + '/api/daemon', headers=headers, json={'options': options.__dict__})
            if not r.status_code == 200:
                print('Failed to contact BioMAJ daemon')
                sys.exit(1)
            result = r.json()
            status = result['status']
            msg = result['msg']

        if options.json:
            if not status:
                print(json.dumps({'error': str(msg)}))
            else:
                print(json.dumps(msg))
        else:
            if not status:
                print('An error occured:\n')
                print(str(msg))
            else:
                if msg:
                    print(str(msg))
                else:
                    print('Done.')
    except Exception as e:
        logging.exception(e)
        print('Error:' + str(e))

if __name__ == '__main__':
    main()