avmtrf1-tools 0.36.0 → 0.38.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +2 -0
  3. data/lib/avmtrf1/git/gitlab.rb +1 -1
  4. data/lib/avmtrf1/git/push_large/lfs_commit/cache.rb +4 -2
  5. data/lib/avmtrf1/git/push_large/lfs_commit.rb +1 -1
  6. data/lib/avmtrf1/git/push_large/source_commit.rb +1 -1
  7. data/lib/avmtrf1/gitlab/commit.rb +5 -0
  8. data/lib/avmtrf1/gitlab/repository.rb +1 -1
  9. data/lib/avmtrf1/{core_ext.rb → tools/core_ext.rb} +0 -0
  10. data/lib/avmtrf1/tools/msgraph/token_retrieve.rb +42 -0
  11. data/lib/avmtrf1/tools/msgraph.rb +11 -0
  12. data/lib/avmtrf1/tools/runner/app_src.rb +1 -1
  13. data/lib/avmtrf1/tools/runner/check_point/login.rb +1 -1
  14. data/lib/avmtrf1/tools/runner/check_point.rb +1 -1
  15. data/lib/avmtrf1/tools/runner/esosti/changed.rb +1 -1
  16. data/lib/avmtrf1/tools/runner/esosti/fetch.rb +1 -1
  17. data/lib/avmtrf1/tools/runner/esosti/request.rb +1 -1
  18. data/lib/avmtrf1/tools/runner/esosti.rb +1 -1
  19. data/lib/avmtrf1/tools/runner/forponto/espelho.rb +1 -1
  20. data/lib/avmtrf1/tools/runner/forponto/marcacoes.rb +1 -1
  21. data/lib/avmtrf1/tools/runner/forponto/resumos.rb +1 -1
  22. data/lib/avmtrf1/tools/runner/forponto/saldo.rb +1 -1
  23. data/lib/avmtrf1/tools/runner/forponto.rb +1 -1
  24. data/lib/avmtrf1/tools/runner/git/gitlab/commit_link.rb +4 -2
  25. data/lib/avmtrf1/tools/runner/git/gitlab.rb +1 -1
  26. data/lib/avmtrf1/tools/runner/git/issues_check.rb +1 -1
  27. data/lib/avmtrf1/tools/runner/git/push_large.rb +1 -1
  28. data/lib/avmtrf1/tools/runner/git.rb +1 -1
  29. data/lib/avmtrf1/tools/runner/msgraph/token.rb +31 -0
  30. data/lib/avmtrf1/tools/runner/msgraph.rb +29 -0
  31. data/lib/avmtrf1/tools/runner/oracle/query.rb +1 -1
  32. data/lib/avmtrf1/tools/runner/oracle/source_get.rb +1 -1
  33. data/lib/avmtrf1/tools/runner/oracle/user_clear.rb +1 -1
  34. data/lib/avmtrf1/tools/runner/oracle.rb +1 -1
  35. data/lib/avmtrf1/tools/runner/red.rb +1 -1
  36. data/lib/avmtrf1/tools/runner/trf1_dspace_base0.rb +1 -1
  37. data/lib/avmtrf1/tools/version.rb +1 -1
  38. data/template/avmtrf1/tools/msgraph/token_retrieve/python_retriever.py +85 -0
  39. metadata +8 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 493f91da0b605f4a9a83c65ad7147af44d9cae1d2776647fc0daeeaa911351ff
4
- data.tar.gz: 4ab6779365c2601f3a913aeeb658ad39f42273f8f6bbc05a93a89817006d89ca
3
+ metadata.gz: 8c87f809a9926218291f4b57af7047d55ca4c612d1dcc034d01775f83d32af80
4
+ data.tar.gz: 3484e235b30f179892ad90db5ad2e82da61c457059cf3945004ce7a56cca62c2
5
5
  SHA512:
6
- metadata.gz: 1b945f2e35f0d2b79be9fb7ec67d9b6cfd2c3c2e0381918626ed966136a2136b50c161844dc78c3b7337abe269ca93aa3eb2d73a9aafc77d7b72a4d7b32ecc36
7
- data.tar.gz: cc0e2ebe992386740b907725086b9e29184bf8f18aded506db9a7f5c3eb774eba38cd86eed6738f89b05a042ad7c06cbf17c15d5e16a0fac146839198acd4f2e
6
+ metadata.gz: 1eac41804ec158176af21b06ca3ae8e09941b7e402059eb94038bac2a14f235d8a574b23a01366c82767c6fb1d099022917bc8fcbb51ad4b8db0b9eb88763266
7
+ data.tar.gz: 5b14500f85e8b0c8c026b28b37fcd9fc3ba9c3f8e1764a15f69f493134bb8ee1654026fb46b293fccb380bab3c448d5a457af58550d68044c3fc69ef1ad26557
data/Gemfile CHANGED
@@ -7,3 +7,5 @@ gemspec
7
7
  group :oracle do
8
8
  gem 'ruby-oci8'
9
9
  end
10
+
11
+ gem 'httpclient', git: 'https://github.com/livelink/httpclient.git'
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'avmtrf1/core_ext'
3
+ require 'avmtrf1/tools/core_ext'
4
4
 
5
5
  module Avmtrf1
6
6
  module Git
@@ -5,8 +5,10 @@ module Avmtrf1
5
5
  class PushLarge
6
6
  class LfsCommit
7
7
  module Cache
8
- def fs_cache_uncached
9
- source_commit.fs_cache.child(lfs_file_min_size.present? ? lfs_file_min_size : 'nil')
8
+ def fs_cache
9
+ @fs_cache ||= source_commit.fs_cache.child(
10
+ lfs_file_min_size.present? ? lfs_file_min_size : 'nil'
11
+ )
10
12
  end
11
13
 
12
14
  %w[sha1 files_size push_pack_error].each do |attr|
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'avmtrf1/core_ext'
3
+ require 'avmtrf1/tools/core_ext'
4
4
 
5
5
  module Avmtrf1
6
6
  module Git
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'avm/git/commit'
4
- require 'avmtrf1/core_ext'
4
+ require 'avmtrf1/tools/core_ext'
5
5
 
6
6
  module Avmtrf1
7
7
  module Git
@@ -13,6 +13,11 @@ module Avmtrf1
13
13
  source
14
14
  end
15
15
 
16
+ # @return [String]
17
+ def markdown_link(object_type = 'commit')
18
+ "[#{git_commit.abbreviated_commit_hash}|#{web_url(object_type)}]"
19
+ end
20
+
16
21
  # @return [String]
17
22
  def textile_link(object_type = 'commit')
18
23
  "\"#{git_commit.abbreviated_commit_hash}\":#{web_url(object_type)}"
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'avmtrf1/core_ext'
3
+ require 'avmtrf1/tools/core_ext'
4
4
 
5
5
  module Avmtrf1
6
6
  module Gitlab
File without changes
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_rest/api'
4
+ require 'eac_ruby_utils/core_ext'
5
+ require 'eac_ruby_utils/fs/temp'
6
+ require 'avmtrf1/template'
7
+
8
+ module Avmtrf1
9
+ module Tools
10
+ module Msgraph
11
+ class TokenRetrieve
12
+ enable_simple_cache
13
+ common_constructor :client_id
14
+
15
+ private
16
+
17
+ def python_retrieve_command(file)
18
+ ::EacRubyUtils::Envs.local.command(python_retrieve_program_path, client_id, file)
19
+ end
20
+
21
+ # @return [Hash]
22
+ def result_uncached
23
+ ::EacRubyUtils::Yaml.load(result_string)
24
+ end
25
+
26
+ # @return [String]
27
+ def result_string
28
+ ::EacRubyUtils::Fs::Temp.on_file do |file|
29
+ raise ::RuntimeError, result.pretty_inspect unless python_retrieve_command(file.to_path)
30
+ .system
31
+
32
+ file.read
33
+ end
34
+ end
35
+
36
+ def python_retrieve_program_path
37
+ template.child('python_retriever.py').path
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avmtrf1
6
+ module Tools
7
+ module Msgraph
8
+ require_sub __FILE__
9
+ end
10
+ end
11
+ end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'avm/tools/runner/app_src'
4
- require 'avmtrf1/core_ext'
4
+ require 'avmtrf1/tools/core_ext'
5
5
 
6
6
  module Avmtrf1
7
7
  module Tools
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'avmtrf1/check_point/session'
4
- require 'avmtrf1/core_ext'
4
+ require 'avmtrf1/tools/core_ext'
5
5
 
6
6
  module Avmtrf1
7
7
  module Tools
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'avmtrf1/core_ext'
3
+ require 'avmtrf1/tools/core_ext'
4
4
 
5
5
  module Avmtrf1
6
6
  module Tools
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'avmtrf1/core_ext'
3
+ require 'avmtrf1/tools/core_ext'
4
4
 
5
5
  module Avmtrf1
6
6
  module Tools
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'avmtrf1/core_ext'
3
+ require 'avmtrf1/tools/core_ext'
4
4
 
5
5
  module Avmtrf1
6
6
  module Tools
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'avmtrf1/core_ext'
3
+ require 'avmtrf1/tools/core_ext'
4
4
  require 'yaml'
5
5
 
6
6
  module Avmtrf1
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'avmtrf1/core_ext'
3
+ require 'avmtrf1/tools/core_ext'
4
4
  require 'avmtrf1/default_esosti'
5
5
 
6
6
  module Avmtrf1
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'avmtrf1/core_ext'
3
+ require 'avmtrf1/tools/core_ext'
4
4
 
5
5
  module Avmtrf1
6
6
  module Tools
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'avmtrf1/forponto/user/day_registers'
4
- require 'avmtrf1/core_ext'
4
+ require 'avmtrf1/tools/core_ext'
5
5
 
6
6
  module Avmtrf1
7
7
  module Tools
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'avmtrf1/core_ext'
3
+ require 'avmtrf1/tools/core_ext'
4
4
 
5
5
  module Avmtrf1
6
6
  module Tools
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'avmtrf1/core_ext'
3
+ require 'avmtrf1/tools/core_ext'
4
4
  require 'avmtrf1/forponto/user/balance'
5
5
 
6
6
  module Avmtrf1
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'eac_config/node'
4
- require 'avmtrf1/core_ext'
4
+ require 'avmtrf1/tools/core_ext'
5
5
  require 'avmtrf1/forponto/user'
6
6
 
7
7
  module Avmtrf1
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'avm/tools/runner/git'
4
- require 'avmtrf1/core_ext'
4
+ require 'avmtrf1/tools/core_ext'
5
5
  require 'avmtrf1/gitlab/commit'
6
6
  require 'avmtrf1/gitlab/repository'
7
7
 
@@ -13,6 +13,7 @@ module Avmtrf1
13
13
  class CommitLink
14
14
  runner_with :help, :output do
15
15
  desc 'Mostra o link de uma revisão no Gitlab do TRF1.'
16
+ bool_opt '-m', '--markdown', 'Formata URL como link Markdown.'
16
17
  bool_opt '-t', '--tree', 'URL com "tree" no lugar de "commit".'
17
18
  bool_opt '-T', '--textile', 'Formata URL como link Textile.'
18
19
  pos_arg 'revisions', optional: true, repeat: true
@@ -48,7 +49,8 @@ module Avmtrf1
48
49
 
49
50
  # @return [String]
50
51
  def commit_output(commit)
51
- return commit.textile_link if parsed.textile?
52
+ return commit.textile_link(object_type) if parsed.textile?
53
+ return commit.markdown_link(object_type) if parsed.markdown?
52
54
 
53
55
  commit.web_url(object_type)
54
56
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'avm/tools/runner/git'
4
- require 'avmtrf1/core_ext'
4
+ require 'avmtrf1/tools/core_ext'
5
5
 
6
6
  module Avmtrf1
7
7
  module Tools
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'avmtrf1/core_ext'
3
+ require 'avmtrf1/tools/core_ext'
4
4
  require 'avmtrf1/git/cached_repository'
5
5
 
6
6
  module Avmtrf1
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'avmtrf1/core_ext'
3
+ require 'avmtrf1/tools/core_ext'
4
4
  require 'avmtrf1/git/push_large'
5
5
 
6
6
  module Avmtrf1
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'avm/tools/runner/git'
4
- require 'avmtrf1/core_ext'
4
+ require 'avmtrf1/tools/core_ext'
5
5
 
6
6
  module Avmtrf1
7
7
  module Tools
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avmtrf1/tools/core_ext'
4
+ require 'avmtrf1/tools/msgraph/token_retrieve'
5
+
6
+ module Avmtrf1
7
+ module Tools
8
+ class Runner
9
+ class Msgraph
10
+ class Token
11
+ runner_with :help, :output
12
+
13
+ def run
14
+ infov 'Client ID', token_retrieve.client_id
15
+ run_output
16
+ end
17
+
18
+ private
19
+
20
+ def output_content
21
+ ::EacRubyUtils::Yaml.dump(token_retrieve.result)
22
+ end
23
+
24
+ def token_retrieve_uncached
25
+ ::Avmtrf1::Tools::Msgraph::TokenRetrieve.new(runner_context.call(:client_id))
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avmtrf1/tools/core_ext'
4
+
5
+ module Avmtrf1
6
+ module Tools
7
+ class Runner
8
+ class Msgraph
9
+ require_sub __FILE__
10
+ runner_with :help, :subcommands do
11
+ arg_opt '-i', '--client-id', 'ID de aplicação cliente alternativo.'
12
+ subcommands
13
+ end
14
+
15
+ def client_id
16
+ client_id_by_argument || client_id_by_config
17
+ end
18
+
19
+ def client_id_by_argument
20
+ parsed.client_id.presence
21
+ end
22
+
23
+ def client_id_by_config
24
+ ::EacConfig::Node.context.current.entry('msgraph.client_id').value
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'avmtrf1/core_ext'
3
+ require 'avmtrf1/tools/core_ext'
4
4
 
5
5
  module Avmtrf1
6
6
  module Tools
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'avmtrf1/core_ext'
3
+ require 'avmtrf1/tools/core_ext'
4
4
 
5
5
  module Avmtrf1
6
6
  module Tools
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'avmtrf1/core_ext'
3
+ require 'avmtrf1/tools/core_ext'
4
4
 
5
5
  module Avmtrf1
6
6
  module Tools
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'avmtrf1/core_ext'
3
+ require 'avmtrf1/tools/core_ext'
4
4
  require 'avmtrf1/oracle/connection/base.rb'
5
5
  require 'avmtrf1/oracle/connection/string_builder.rb'
6
6
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'avmtrf1/core_ext'
3
+ require 'avmtrf1/tools/core_ext'
4
4
  require 'avmtrf1/ini'
5
5
  require 'avmtrf1/red/profile'
6
6
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'avmtrf1/core_ext'
3
+ require 'avmtrf1/tools/core_ext'
4
4
  require 'avmtrf1/trf1_dspace_base0/instance'
5
5
 
6
6
  module Avmtrf1
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avmtrf1
4
4
  module Tools
5
- VERSION = '0.36.0'
5
+ VERSION = '0.38.1'
6
6
  end
7
7
  end
@@ -0,0 +1,85 @@
1
+ #!/usr/bin/env python3
2
+
3
+ # Requirements
4
+ # pyperclip>=1.6.0
5
+ # requests>=2.18.4
6
+ # adal>=1.0.0
7
+ # pyyaml
8
+
9
+ from adal import AuthenticationContext
10
+ import argparse
11
+ import pyperclip
12
+ import sys
13
+ import webbrowser
14
+ import yaml
15
+
16
+
17
+ class Config:
18
+ AUTHORITY_URL = 'https://login.microsoftonline.com/common'
19
+ RESOURCE = 'https://graph.microsoft.com'
20
+ API_VERSION = 'beta'
21
+
22
+
23
+ class TokenInfo:
24
+ def __init__(self, args):
25
+ self.__device = None
26
+ self.__token = None
27
+ self.__context = None
28
+ self.__args = args
29
+
30
+ def context(self):
31
+ if not self.__context:
32
+ self.__context = AuthenticationContext(Config.AUTHORITY_URL,
33
+ api_version=None)
34
+ return self.__context
35
+
36
+ def device(self):
37
+ if not self.__device:
38
+ self.__device = self.context().acquire_user_code(
39
+ Config.RESOURCE, self.__args.client_id)
40
+ return self.__device
41
+
42
+ def token(self, auto=True):
43
+ if not self.__token:
44
+ device_code = self.device()
45
+ if auto:
46
+ pyperclip.copy(
47
+ device_code['user_code']) # copy user code to clipboard
48
+ webbrowser.open(
49
+ device_code['verification_url']) # open browser
50
+ self.info(
51
+ f'The code {device_code["user_code"]} has been copied to your clipboard, '
52
+ f'and your web browser is opening {device_code["verification_url"]}. '
53
+ 'Paste the code to sign in.\n')
54
+ else:
55
+ self.info(device_code['message'])
56
+
57
+ self.__token = self.context().acquire_token_with_device_code(
58
+ Config.RESOURCE, device_code, self.__args.client_id)
59
+ return self.__token
60
+
61
+ def info(self, message):
62
+ sys.stderr.write(message + "\n")
63
+
64
+ def result(self):
65
+ if self.token():
66
+ return {'device': self.device(), 'token': self.token()}
67
+ else:
68
+ return None
69
+
70
+ def run(self):
71
+ if self.result():
72
+ with open(self.__args.output_path, 'w') as outfile:
73
+ yaml.dump(self.result(), outfile, default_flow_style=False)
74
+ self.info('Result writed in "%s"' % (self.__args.output_path))
75
+ else:
76
+ sys.exit("Result empty!")
77
+
78
+
79
+ if __name__ == '__main__':
80
+ parser = argparse.ArgumentParser(
81
+ description='Recupera token de acesso ao MSGraph')
82
+ parser.add_argument('client_id')
83
+ parser.add_argument('output_path')
84
+ args = parser.parse_args()
85
+ TokenInfo(args).run()
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avmtrf1-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.36.0
4
+ version: 0.38.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eduardo H. Bogoni
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-01-24 00:00:00.000000000 Z
11
+ date: 2022-06-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aranha-selenium
@@ -148,7 +148,6 @@ files:
148
148
  - lib/avmtrf1/check_point.rb
149
149
  - lib/avmtrf1/check_point/session.rb
150
150
  - lib/avmtrf1/check_point/session/login.rb
151
- - lib/avmtrf1/core_ext.rb
152
151
  - lib/avmtrf1/default_esosti.rb
153
152
  - lib/avmtrf1/default_jira.rb
154
153
  - lib/avmtrf1/default_redmine.rb
@@ -284,6 +283,9 @@ files:
284
283
  - lib/avmtrf1/template.rb
285
284
  - lib/avmtrf1/tools.rb
286
285
  - lib/avmtrf1/tools/application.rb
286
+ - lib/avmtrf1/tools/core_ext.rb
287
+ - lib/avmtrf1/tools/msgraph.rb
288
+ - lib/avmtrf1/tools/msgraph/token_retrieve.rb
287
289
  - lib/avmtrf1/tools/runner.rb
288
290
  - lib/avmtrf1/tools/runner/app_src.rb
289
291
  - lib/avmtrf1/tools/runner/check_point.rb
@@ -303,6 +305,8 @@ files:
303
305
  - lib/avmtrf1/tools/runner/git/issues_check.rb
304
306
  - lib/avmtrf1/tools/runner/git/push_large.rb
305
307
  - lib/avmtrf1/tools/runner/inventario_sistemas.rb
308
+ - lib/avmtrf1/tools/runner/msgraph.rb
309
+ - lib/avmtrf1/tools/runner/msgraph/token.rb
306
310
  - lib/avmtrf1/tools/runner/node_js.rb
307
311
  - lib/avmtrf1/tools/runner/node_js/docker.rb
308
312
  - lib/avmtrf1/tools/runner/openvpn.rb
@@ -338,6 +342,7 @@ files:
338
342
  - template/avmtrf1/php/docker_image/aux/setup_apache_site.sh
339
343
  - template/avmtrf1/php/docker_image/aux/start.sh
340
344
  - template/avmtrf1/php/docker_image/aux/templates/apache_site.conf
345
+ - template/avmtrf1/tools/msgraph/token_retrieve/python_retriever.py
341
346
  - template/avmtrf1/trf1_dspace_base0/deploy/build.properties.template
342
347
  homepage: http://redmine.trf1.gov.br/projects/avm-trf1
343
348
  licenses: []