Skip to content

Commit 1b56b4d

Browse files
Merge pull request #799 from Som-Energia/FIX_code_and_scripts_update
Afegir codi i scripts que ja estan en producció
2 parents c135764 + d29f3df commit 1b56b4d

4 files changed

+67
-3
lines changed

scripts/check_cchloader_version.py

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/usr/bin/env python2
2+
# -*- coding: utf-8 -*-
3+
import subprocess
4+
import sys
5+
import pkg_resources
6+
7+
8+
def is_installed_from_repo():
9+
try:
10+
output = subprocess.check_output([sys.executable, '-m', 'pip', 'show', 'cchloader'])
11+
for line in output.split('\n'):
12+
if line.startswith('Location:') and 'gisce' in line:
13+
return True
14+
return False
15+
except subprocess.CalledProcessError:
16+
return False
17+
18+
19+
def is_version_invalid():
20+
try:
21+
version = pkg_resources.get_distribution('cchloader').version
22+
return pkg_resources.parse_version(version) > pkg_resources.parse_version('1.0')
23+
except pkg_resources.DistributionNotFound:
24+
return False
25+
26+
27+
def install_via_pip():
28+
try:
29+
subprocess.check_call([sys.executable, '-m', 'pip', 'install',
30+
'--force-reinstall', 'cchloader'])
31+
print("Paquet 'cchloader' reinstal·lat des de PyPI correctament.")
32+
except subprocess.CalledProcessError:
33+
print("Error: No s'ha pogut instal·lar 'cchloader' des de PyPI.")
34+
sys.exit(1)
35+
36+
37+
def main():
38+
if is_installed_from_repo():
39+
print("El paquet 'cchloader' està instal·lat des de repositori. Reinstal·lant des de PyPI...") # noqa: E501
40+
install_via_pip()
41+
sys.exit(1)
42+
elif is_version_invalid():
43+
print("La versió de 'cchloader' és superior a 1.0. Reinstal·lant des de PyPI...")
44+
install_via_pip()
45+
sys.exit(1)
46+
else:
47+
print("El paquet 'cchloader' està correctament instal·lat. No cal fer res.")
48+
sys.exit(0)
49+
50+
51+
if __name__ == '__main__':
52+
main()

scripts/kill_firefox.sh

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
# check utility
4+
message=$(pkill -f /usr/lib/firefox/firefox)
5+
6+
# echo message
7+
echo "All Firefox must die"
8+
echo $message
9+
10+
# if you want allways have a OK response
11+
exit 0

scripts/requeue_failed.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
INTERVAL = 1200 # Seconds
1313
MAX_ATTEMPTS = 5
14-
QUEUES_TO_REQUEUE = ["cups_cch", "tm_validate", "sii"]
15-
QUEUES_TO_DELETE = ["jobspool-autoworker", "profiling", "make_invoices"]
14+
QUEUES_TO_REQUEUE = ["cups_cch", "sii"]
15+
QUEUES_TO_DELETE = ["jobspool-autoworker", "profiling", "make_invoices", "tm_validate", "cch_loaderX"] # noqa: E501
1616
EXECINFO_TO_DELETE = [
1717
"Work-horse process was terminated unexpectedly",
1818
"es mes petita que la data inicial",
@@ -22,6 +22,7 @@
2222
"RepresenterError: ('cannot represent an object', <osv.orm.browse_null object at 0x7f3148f11a90>)", # noqa: E501
2323
"You try to write on an record that doesn't exist",
2424
"cursor, uid, line_id, ['import_phase'])['import_phase']\nTypeError: 'bool' object has no attribute '__getitem__'", # noqa: E501
25+
"Registrator for meter id GSM501815908 is not found",
2526
]
2627
QUEUES_TO_DELETE_AFETER_REQUE = ["sii"]
2728

scripts/update_gisce_forks.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ echo "=============================="
2020

2121
# Push local branch to repo
2222
cd /home/erp/src/erp
23-
git push
23+
git push somenergia rolling_erp01

0 commit comments

Comments
 (0)