Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style: format code with Black and PHP CS Fixer #601

Merged
merged 1 commit into from
Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 18 additions & 17 deletions services/contrib/test-xmlrpc.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@

function decode_entities($text)
{
$text = html_entity_decode($text,ENT_QUOTES,"ISO-8859-1"); /* NOTE: UTF-8 does not work! */
$text= preg_replace('/&#(\d+);/me',"chr(\\1)",$text); /* decimal notation */
$text= preg_replace('/&#x([a-f0-9]+);/mei',"chr(0x\\1)",$text); /* hex notation */
$text = html_entity_decode($text, ENT_QUOTES, "ISO-8859-1"); /* NOTE: UTF-8 does not work! */
$text = preg_replace('/&#(\d+);/me', "chr(\\1)", $text); /* decimal notation */
$text = preg_replace('/&#x([a-f0-9]+);/mei', "chr(0x\\1)", $text); /* hex notation */
return $text;
}

Expand All @@ -38,7 +38,7 @@ function decode_entities($text)
$conf["host"] = "127.0.0.1";
$conf["port"] = "8001";
$conf["scheme"] = "http";
$conf["debug"]["level"]="0";
$conf["debug"]["level"] = "0";
}

$params = $_SERVER["argv"];
Expand All @@ -47,13 +47,13 @@ function decode_entities($text)

$output_options = array( "output_type" => "xml", "verbosity" => "pretty", "escaping" => array("markup", "non-ascii", "non-print"), "version" => "xmlrpc", "encoding" => "UTF-8" );

$method="sync_remote_exec";
$params=array(
$method = "sync_remote_exec";
$params = array(
1,
"cd /tmp; more.com OOo2.log.txt",
array(
'host'=> 'medulla-win2k',
'protocol'=> 'ssh'
'host' => 'medulla-win2k',
'protocol' => 'ssh'
)
);

Expand All @@ -67,7 +67,7 @@ function decode_entities($text)
}
*/
/* We build the HTTP POST that will be sent */
$host= $conf["host"].":".$conf["port"];
$host = $conf["host"].":".$conf["port"];
$url = "/";
$httpQuery = "POST ". $url ." HTTP/1.0\r\n";
$httpQuery .= "User-Agent: xmlrpc\r\n";
Expand All @@ -94,7 +94,7 @@ function decode_entities($text)
}

/* Send the HTTP POST */
if ( !fwrite($sock, $httpQuery, strlen($httpQuery)) ) {
if (!fwrite($sock, $httpQuery, strlen($httpQuery))) {
print("Can't send XML-RPC request to MMC agent");
exit(-1);
}
Expand Down Expand Up @@ -134,8 +134,9 @@ function decode_entities($text)
So we need to test this special case.
*/
$booleanFalse = "<?xml version='1.0'?>\n<methodResponse>\n<params>\n<param>\n<value><boolean>0</boolean></value>\n</param>\n</params>\n</methodResponse>\n";
if ($xmlResponse == $booleanFalse) $xmlResponse = "0";
else {
if ($xmlResponse == $booleanFalse) {
$xmlResponse = "0";
} else {
$xmlResponseTmp = xmlrpc_decode($xmlResponse, "UTF-8");
/* if we cannot decode in UTF-8 */
if (!$xmlResponseTmp) {
Expand All @@ -149,19 +150,19 @@ function decode_entities($text)
}

/* If debug is on, print the XML-RPC call and result */
if ($conf["debug"]["level"]!=0) {
if ($conf["debug"]["level"] != 0) {
$str = '<div id="debugCode">';
$str .= "&nbsp;&nbsp;debuginfo";
$str.= '<div id="debugCodeHeader">';
$str .= '<div id="debugCodeHeader">';
$str .= "XML RPC CALL FUNCTION: $method(";
if (!$params) {
$params = "null";
} elseif (is_array($params)) {
$str .= implode(',',$params);
$str .= implode(',', $params);
} else {
$str .= $params;
}
$str .=')';
$str .= ')';
$str .= "</div>";
if (is_array($xmlResponse)) {
$str .= "<pre>";
Expand All @@ -176,7 +177,7 @@ function decode_entities($text)
}

/* If the XML-RPC server sent a fault, display an error */
if (($xmlResponse["faultCode"])&&(is_array($xmlResponse))) {
if (($xmlResponse["faultCode"]) && (is_array($xmlResponse))) {
print($xmlResponse["faultCode"].":".$xmlResponse["faultString"]."\n");
exit -1;
}
Expand Down
4 changes: 3 additions & 1 deletion services/medulla/database/inventory/entitiesrules.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ class EntitiesRules:
It allows the inventory server to assign a computer to an entity.
"""

def __init__(self, conffile=mmcconfdir + "/medulla/inventory-server/entities-rules"):
def __init__(
self, conffile=mmcconfdir + "/medulla/inventory-server/entities-rules"
):
self.logger = logging.getLogger()
self.conf = conffile
self.rules = []
Expand Down
13 changes: 11 additions & 2 deletions services/medulla/database/xmppmaster/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5201,7 +5201,11 @@ def get_deploy_by_team_member(
Deploy.sessionid.like("%s%%" % typedeploy)
)

if not medulla_usersid or len(medulla_usersid) == 1 and medulla_usersid[0] == "root":
if (
not medulla_usersid
or len(medulla_usersid) == 1
and medulla_usersid[0] == "root"
):
return self.get_deploy_by_user_with_interval(
login,
state,
Expand Down Expand Up @@ -7270,7 +7274,12 @@ def write_topologyfile(self, topology):
# creation topology file.
filename = "topology.json"
pathfile = os.path.join(directoryjson, filename)
builddatajson = {"name": "Medulla", "type": "AMR", "parent": None, "children": []}
builddatajson = {
"name": "Medulla",
"type": "AMR",
"parent": None,
"children": [],
}
for i in topology:
listmachines = topology[i]

Expand Down
5 changes: 4 additions & 1 deletion services/medulla/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,10 @@ def test_with_int(self):
def test_with_dict(self):
"""Test with dict
Test 22"""
assert medulla.utils.unique({"c": ["a", "b"], "b": (0, 0), "c": 4}) == ["c", "b"]
assert medulla.utils.unique({"c": ["a", "b"], "b": (0, 0), "c": 4}) == [
"c",
"b",
]

def test_without_parameters(self):
"""Test without parameters
Expand Down
20 changes: 15 additions & 5 deletions services/mmc/plugins/glpi/database_100.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,9 @@ def initMappers(self):
Table(
"glpi_items_%s" % i,
self.metadata,
Column("items_id", Integer, ForeignKey("glpi_computers_medulla.id")),
Column(
"items_id", Integer, ForeignKey("glpi_computers_medulla.id")
),
Column("%s_id" % i, Integer, ForeignKey("glpi_%s.id" % i)),
autoload=True,
),
Expand Down Expand Up @@ -373,7 +375,9 @@ def initMappers(self):
self.fusionantivirus = Table(
"glpi_computerantiviruses",
self.metadata,
Column("computers_id", Integer, ForeignKey("glpi_computers_medulla.id")),
Column(
"computers_id", Integer, ForeignKey("glpi_computers_medulla.id")
),
Column(
"manufacturers_id", Integer, ForeignKey("glpi_manufacturers.id")
),
Expand All @@ -399,7 +403,9 @@ def initMappers(self):
self.fusionlocks = Table(
"glpi_plugin_fusioninventory_locks",
self.metadata,
Column("items_id", Integer, ForeignKey("glpi_computers_medulla.id")),
Column(
"items_id", Integer, ForeignKey("glpi_computers_medulla.id")
),
autoload=True,
)
mapper(FusionLocks, self.fusionlocks)
Expand Down Expand Up @@ -721,7 +727,9 @@ def initMappers(self):
self.regcontents = Table(
"glpi_plugin_fusioninventory_collects_registries_contents",
self.metadata,
Column("computers_id", Integer, ForeignKey("glpi_computers_medulla.id")),
Column(
"computers_id", Integer, ForeignKey("glpi_computers_medulla.id")
),
Column(
"plugin_fusioninventory_collects_registries_id",
Integer,
Expand All @@ -734,7 +742,9 @@ def initMappers(self):
self.regcontents = Table(
"glpi_plugin_glpiinventory_collects_registries_contents",
self.metadata,
Column("computers_id", Integer, ForeignKey("glpi_computers_medulla.id")),
Column(
"computers_id", Integer, ForeignKey("glpi_computers_medulla.id")
),
Column(
"plugin_glpiinventory_collects_registries_id",
Integer,
Expand Down
12 changes: 9 additions & 3 deletions services/mmc/plugins/glpi/database_92.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,9 @@ def initMappers(self):
Table(
"glpi_items_%s" % i,
self.metadata,
Column("items_id", Integer, ForeignKey("glpi_computers_medulla.id")),
Column(
"items_id", Integer, ForeignKey("glpi_computers_medulla.id")
),
Column("%s_id" % i, Integer, ForeignKey("glpi_%s.id" % i)),
autoload=True,
),
Expand Down Expand Up @@ -375,7 +377,9 @@ def initMappers(self):
self.fusionantivirus = Table(
"glpi_computerantiviruses",
self.metadata,
Column("computers_id", Integer, ForeignKey("glpi_computers_medulla.id")),
Column(
"computers_id", Integer, ForeignKey("glpi_computers_medulla.id")
),
Column(
"manufacturers_id", Integer, ForeignKey("glpi_manufacturers.id")
),
Expand Down Expand Up @@ -408,7 +412,9 @@ def initMappers(self):
self.fusionagents = Table(
"glpi_plugin_fusioninventory_agents",
self.metadata,
Column("computers_id", Integer, ForeignKey("glpi_computers_medulla.id")),
Column(
"computers_id", Integer, ForeignKey("glpi_computers_medulla.id")
),
autoload=True,
)
mapper(FusionAgents, self.fusionagents)
Expand Down
12 changes: 9 additions & 3 deletions services/mmc/plugins/glpi/database_93.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,9 @@ def initMappers(self):
Table(
"glpi_items_%s" % i,
self.metadata,
Column("items_id", Integer, ForeignKey("glpi_computers_medulla.id")),
Column(
"items_id", Integer, ForeignKey("glpi_computers_medulla.id")
),
Column("%s_id" % i, Integer, ForeignKey("glpi_%s.id" % i)),
autoload=True,
),
Expand Down Expand Up @@ -387,7 +389,9 @@ def initMappers(self):
self.fusionantivirus = Table(
"glpi_computerantiviruses",
self.metadata,
Column("computers_id", Integer, ForeignKey("glpi_computers_medulla.id")),
Column(
"computers_id", Integer, ForeignKey("glpi_computers_medulla.id")
),
Column(
"manufacturers_id", Integer, ForeignKey("glpi_manufacturers.id")
),
Expand Down Expand Up @@ -420,7 +424,9 @@ def initMappers(self):
self.fusionagents = Table(
"glpi_plugin_fusioninventory_agents",
self.metadata,
Column("computers_id", Integer, ForeignKey("glpi_computers_medulla.id")),
Column(
"computers_id", Integer, ForeignKey("glpi_computers_medulla.id")
),
autoload=True,
)
mapper(FusionAgents, self.fusionagents)
Expand Down
12 changes: 9 additions & 3 deletions services/mmc/plugins/glpi/database_94.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,9 @@ def initMappers(self):
Table(
"glpi_items_%s" % i,
self.metadata,
Column("items_id", Integer, ForeignKey("glpi_computers_medulla.id")),
Column(
"items_id", Integer, ForeignKey("glpi_computers_medulla.id")
),
Column("%s_id" % i, Integer, ForeignKey("glpi_%s.id" % i)),
autoload=True,
),
Expand Down Expand Up @@ -376,7 +378,9 @@ def initMappers(self):
self.fusionantivirus = Table(
"glpi_computerantiviruses",
self.metadata,
Column("computers_id", Integer, ForeignKey("glpi_computers_medulla.id")),
Column(
"computers_id", Integer, ForeignKey("glpi_computers_medulla.id")
),
Column(
"manufacturers_id", Integer, ForeignKey("glpi_manufacturers.id")
),
Expand Down Expand Up @@ -409,7 +413,9 @@ def initMappers(self):
self.fusionagents = Table(
"glpi_plugin_fusioninventory_agents",
self.metadata,
Column("computers_id", Integer, ForeignKey("glpi_computers_medulla.id")),
Column(
"computers_id", Integer, ForeignKey("glpi_computers_medulla.id")
),
autoload=True,
)
mapper(FusionAgents, self.fusionagents)
Expand Down
12 changes: 9 additions & 3 deletions services/mmc/plugins/glpi/database_95.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,9 @@ def initMappers(self):
Table(
"glpi_items_%s" % i,
self.metadata,
Column("items_id", Integer, ForeignKey("glpi_computers_medulla.id")),
Column(
"items_id", Integer, ForeignKey("glpi_computers_medulla.id")
),
Column("%s_id" % i, Integer, ForeignKey("glpi_%s.id" % i)),
autoload=True,
),
Expand Down Expand Up @@ -391,7 +393,9 @@ def initMappers(self):
self.fusionantivirus = Table(
"glpi_computerantiviruses",
self.metadata,
Column("computers_id", Integer, ForeignKey("glpi_computers_medulla.id")),
Column(
"computers_id", Integer, ForeignKey("glpi_computers_medulla.id")
),
Column(
"manufacturers_id", Integer, ForeignKey("glpi_manufacturers.id")
),
Expand Down Expand Up @@ -424,7 +428,9 @@ def initMappers(self):
self.fusionagents = Table(
"glpi_plugin_fusioninventory_agents",
self.metadata,
Column("computers_id", Integer, ForeignKey("glpi_computers_medulla.id")),
Column(
"computers_id", Integer, ForeignKey("glpi_computers_medulla.id")
),
autoload=True,
)
mapper(FusionAgents, self.fusionagents)
Expand Down
12 changes: 9 additions & 3 deletions services/mmc/plugins/glpi/database_itsm_ng_14.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,9 @@ def initMappers(self):
Table(
"glpi_items_%s" % i,
self.metadata,
Column("items_id", Integer, ForeignKey("glpi_computers_medulla.id")),
Column(
"items_id", Integer, ForeignKey("glpi_computers_medulla.id")
),
Column("%s_id" % i, Integer, ForeignKey("glpi_%s.id" % i)),
autoload=True,
),
Expand Down Expand Up @@ -379,7 +381,9 @@ def initMappers(self):
self.fusionantivirus = Table(
"glpi_computerantiviruses",
self.metadata,
Column("computers_id", Integer, ForeignKey("glpi_computers_medulla.id")),
Column(
"computers_id", Integer, ForeignKey("glpi_computers_medulla.id")
),
Column(
"manufacturers_id", Integer, ForeignKey("glpi_manufacturers.id")
),
Expand Down Expand Up @@ -412,7 +416,9 @@ def initMappers(self):
self.fusionagents = Table(
"glpi_plugin_fusioninventory_agents",
self.metadata,
Column("computers_id", Integer, ForeignKey("glpi_computers_medulla.id")),
Column(
"computers_id", Integer, ForeignKey("glpi_computers_medulla.id")
),
autoload=True,
)
mapper(FusionAgents, self.fusionagents)
Expand Down
4 changes: 3 additions & 1 deletion services/mmc/plugins/medulla_server/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,9 @@ def getSSHPublicKey():

def updateDebianSourceList():
try:
installation_uuid = open("/etc/medulla-licensing/installation_id").read().strip()
installation_uuid = (
open("/etc/medulla-licensing/installation_id").read().strip()
)
except IOError:
logging.getLogger().error("Error while reading installation_id file")
try:
Expand Down
6 changes: 5 additions & 1 deletion services/mmc/plugins/pkgs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,11 @@ def putPackageDetail(package, need_assign=True):
generate_hash(package["localisation_server"], package["id"])

for key in package:
package[key] = package[key].decode("utf-8") if isinstance(package[key], bytes) else package[key]
package[key] = (
package[key].decode("utf-8")
if isinstance(package[key], bytes)
else package[key]
)

confjson = {
"sub_packages": [],
Expand Down
Loading