Upload files to "/"
This commit is contained in:
		
						commit
						654efaea1f
					
				
							
								
								
									
										185
									
								
								dobby.ipynb
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										185
									
								
								dobby.ipynb
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,185 @@ | ||||
| { | ||||
|  "cells": [ | ||||
|   { | ||||
|    "cell_type": "code", | ||||
|    "execution_count": null, | ||||
|    "metadata": {}, | ||||
|    "outputs": [], | ||||
|    "source": [ | ||||
|     "from selenium import webdriver\n", | ||||
|     "from selenium.common.exceptions import NoSuchElementException\n", | ||||
|     "from neo4j import GraphDatabase\n", | ||||
|     "\n", | ||||
|     "uri = \"bolt://localhost:7687\"\n", | ||||
|     "userName = \"neo4j\"\n", | ||||
|     "password = \"org\"\n", | ||||
|     "graphDB_Driver = GraphDatabase.driver(uri, auth=(userName, password)) " | ||||
|    ] | ||||
|   }, | ||||
|   { | ||||
|    "cell_type": "code", | ||||
|    "execution_count": null, | ||||
|    "metadata": {}, | ||||
|    "outputs": [], | ||||
|    "source": [ | ||||
|     "projekte = \"https://dobby.ppi.int/cgi-bin/ad/adgroups.pl?ou=Projekte\"\n", | ||||
|     "\n", | ||||
|     "driver = webdriver.Firefox()\n", | ||||
|     "driver.get(projekte)\n", | ||||
|     "table = driver.find_element(\"xpath\", \"/html/body/div/div/table[2]\")\n", | ||||
|     "\n", | ||||
|     "groupsPpiX = []\n", | ||||
|     "\n", | ||||
|     "for row in table.find_elements(\"xpath\", \".//tr[not(position()=1)]\"):\n", | ||||
|     "    try:\n", | ||||
|     "        groupId = row.find_element(\"xpath\", \".//td[1]\").text\n", | ||||
|     "        groupDesc = row.find_element(\"xpath\", \".//td[2]\").text\n", | ||||
|     "        if groupId[:8] == 'prj_ppix':\n", | ||||
|     "            groupsPpiX.append([groupId, groupDesc])\n", | ||||
|     "    except NoSuchElementException:\n", | ||||
|     "        print(\"NoSuchElementException\")\n", | ||||
|     "driver.close()" | ||||
|    ] | ||||
|   }, | ||||
|   { | ||||
|    "cell_type": "code", | ||||
|    "execution_count": null, | ||||
|    "metadata": {}, | ||||
|    "outputs": [], | ||||
|    "source": [ | ||||
|     "driver = webdriver.Firefox()\n", | ||||
|     "\n", | ||||
|     "personen = set()\n", | ||||
|     "\n", | ||||
|     "for group, groupDesc in groupsPpiX:\n", | ||||
|     "    driver.get(\"https://dobby.ppi.int/cgi-bin/ad/adgroups.pl?group=\" + group)\n", | ||||
|     "    table = driver.find_element(\"xpath\", \"/html/body/div/div/table[2]/tbody\")\n", | ||||
|     "\n", | ||||
|     "    personenInGruppe = []\n", | ||||
|     "\n", | ||||
|     "    for row in table.find_elements(\"xpath\", \".//tr[not(position()=1)]\"):\n", | ||||
|     "        try:\n", | ||||
|     "            kuerzel = row.find_element(\"xpath\", \".//td[1]\").text\n", | ||||
|     "            name = row.find_element(\"xpath\", \".//td[2]\").text\n", | ||||
|     "            personenInGruppe.append([kuerzel, name])\n", | ||||
|     "            personen.add(kuerzel)\n", | ||||
|     "        except NoSuchElementException:\n", | ||||
|     "            print(\"NoSuchElementException\")\n", | ||||
|     "\n", | ||||
|     "    with graphDB_Driver.session() as graphDB_Session:\n", | ||||
|     "        #Gruppe anlegen\n", | ||||
|     "        graphDB_Session.run(\"\"\"CREATE (:ADGROUP {name: $name})\"\"\", name=group)\n", | ||||
|     "\n", | ||||
|     "        #Personen zur Gruppe verknüpfen\n", | ||||
|     "        for kuerzel, name in personenInGruppe:\n", | ||||
|     "            g = graphDB_Session.run(\"\"\"MATCH (u:USER)\n", | ||||
|     "                                        WHERE u.displayName = $displayName\n", | ||||
|     "                                        RETURN u.kuerzel\"\"\", displayName=name).values()\n", | ||||
|     "            if g:\n", | ||||
|     "                #Person existiert\n", | ||||
|     "                for item in g:\n", | ||||
|     "                    if not item[0]:\n", | ||||
|     "                        #Attribut existiert nicht\n", | ||||
|     "                        graphDB_Session.run(\"\"\"MATCH (u:USER)\n", | ||||
|     "                                                WHERE u.displayName = $displayName\n", | ||||
|     "                                                SET u.kuerzel = $kuerzel\"\"\", \n", | ||||
|     "                                                displayName=name,\n", | ||||
|     "                                                kuerzel=kuerzel)\n", | ||||
|     "            else:\n", | ||||
|     "                #Person existiert nicht\n", | ||||
|     "                #print(name, 'existiert nicht')\n", | ||||
|     "                graphDB_Session.run(\"\"\"CREATE (u:USER {displayName: $displayName, \n", | ||||
|     "                                                    kuerzel: $kuerzel})\"\"\", \n", | ||||
|     "                                        displayName=name,\n", | ||||
|     "                                        kuerzel=kuerzel)\n", | ||||
|     "            # Gruppenbeziehung anlegen\n", | ||||
|     "            graphDB_Session.run(\"MATCH (grp:ADGROUP {name: $name}), (u:USER {displayName: $displayName}) MERGE (u)-[:is_member]->(grp)\",\n", | ||||
|     "                                        name=group,\n", | ||||
|     "                                        displayName=name)\n", | ||||
|     "driver.close()\n" | ||||
|    ] | ||||
|   }, | ||||
|   { | ||||
|    "cell_type": "code", | ||||
|    "execution_count": null, | ||||
|    "metadata": {}, | ||||
|    "outputs": [], | ||||
|    "source": [ | ||||
|     "driver = webdriver.Firefox()\n", | ||||
|     "\n", | ||||
|     "with graphDB_Driver.session() as graphDB_Session:\n", | ||||
|     "    for kuerzel in personen:\n", | ||||
|     "        driver.get(\"https://dobby.ppi.int/cgi-bin/ad/adgroups.pl?user=\" + kuerzel)\n", | ||||
|     "        field = driver.find_element(\"xpath\", \"/html/body/div/div/table[2]/tbody/tr[7]/td[2]\")\n", | ||||
|     "\n", | ||||
|     "        for team in field.text.split('\\n'):\n", | ||||
|     "            graphDB_Session.run(\"MERGE (t:TEAMS {name: $name})\", name=team)\n", | ||||
|     "            graphDB_Session.run(\"MATCH (t:TEAMS {name: $name}), (u:USER {kuerzel: $kuerzel}) MERGE (u)-[:is_member]->(t)\",\n", | ||||
|     "                                        name=team,\n", | ||||
|     "                                        kuerzel=kuerzel)\n", | ||||
|     "driver.close()" | ||||
|    ] | ||||
|   }, | ||||
|   { | ||||
|    "cell_type": "code", | ||||
|    "execution_count": null, | ||||
|    "metadata": {}, | ||||
|    "outputs": [], | ||||
|    "source": [ | ||||
|     "# Personen unter Sascha, die nicht in dem Teams Kanal WS_PPI_X sind\n", | ||||
|     "with graphDB_Driver.session() as graphDB_Session:\n", | ||||
|     "    g = graphDB_Session.run(\"\"\"MATCH (s:USER {displayName: \"Sascha Däsler\"}) -[:vorgesetzter*]-> (u:USER)\n", | ||||
|     "                                MATCH (ad:TEAMS {name: \"WS_PPI_X\"})\n", | ||||
|     "                                WHERE not (u) -[:is_member]-> (ad)\n", | ||||
|     "                                CALL {with u match (v:USER) -[:vorgesetzter]-> (u) return v.displayName as vorgesetzter}\n", | ||||
|     "                                RETURN vorgesetzter, u.jobTitle, u.displayName\n", | ||||
|     "                                ORDER BY vorgesetzter, TOLOWER(u.jobTitle), u.displayName\"\"\").values()\n", | ||||
|     "g" | ||||
|    ] | ||||
|   }, | ||||
|   { | ||||
|    "cell_type": "code", | ||||
|    "execution_count": null, | ||||
|    "metadata": {}, | ||||
|    "outputs": [], | ||||
|    "source": [ | ||||
|     "# Personen unter Sascha, die nicht in der AD Gruppe prj_ppix sind\n", | ||||
|     "with graphDB_Driver.session() as graphDB_Session:\n", | ||||
|     "    g = graphDB_Session.run(\"\"\"match (s:USER {displayName: \"Sascha Däsler\"}) -[:vorgesetzter*]-> (u:USER)\n", | ||||
|     "                                match (ad:ADGROUP {name: \"prj_ppix\"})\n", | ||||
|     "                                where not (u) -[:is_member]-> (ad)\n", | ||||
|     "                                call {with u match (v:USER) -[:vorgesetzter]-> (u) return v.displayName as vorgesetzter}\n", | ||||
|     "                                RETURN vorgesetzter, u.jobTitle, u.displayName\n", | ||||
|     "                                ORDER BY vorgesetzter, TOLOWER(u.jobTitle), u.displayName\"\"\").values()\n", | ||||
|     "g" | ||||
|    ] | ||||
|   } | ||||
|  ], | ||||
|  "metadata": { | ||||
|   "kernelspec": { | ||||
|    "display_name": "venv", | ||||
|    "language": "python", | ||||
|    "name": "python3" | ||||
|   }, | ||||
|   "language_info": { | ||||
|    "codemirror_mode": { | ||||
|     "name": "ipython", | ||||
|     "version": 3 | ||||
|    }, | ||||
|    "file_extension": ".py", | ||||
|    "mimetype": "text/x-python", | ||||
|    "name": "python", | ||||
|    "nbconvert_exporter": "python", | ||||
|    "pygments_lexer": "ipython3", | ||||
|    "version": "3.10.9" | ||||
|   }, | ||||
|   "orig_nbformat": 4, | ||||
|   "vscode": { | ||||
|    "interpreter": { | ||||
|     "hash": "28676787f946bb7f76164fe7d563a7ae5bf108f75fcb12ae9589f51e6258b2b8" | ||||
|    } | ||||
|   } | ||||
|  }, | ||||
|  "nbformat": 4, | ||||
|  "nbformat_minor": 2 | ||||
| } | ||||
							
								
								
									
										1285
									
								
								geckodriver.log
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1285
									
								
								geckodriver.log
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										32
									
								
								json für geburtstag.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								json für geburtstag.json
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,32 @@ | ||||
| // post https://graph.microsoft.com/v1.0/me/events | ||||
| 
 | ||||
| { | ||||
|     "subject": "Clemens", | ||||
|     "isReminderOn": false, | ||||
|     "sensitivity": "private", | ||||
|     "showAs": "free", | ||||
|     "isAllDay": true, | ||||
|     "start": { | ||||
|         "dateTime": "2023-04-26T00:00:00.000Z", | ||||
|         "timeZone": "UTC" | ||||
|     }, | ||||
|     "end": { | ||||
|         "dateTime": "2023-04-27T00:00:00.000Z", | ||||
|         "timeZone": "UTC" | ||||
|     }, | ||||
|     "recurrence": { | ||||
|         "pattern": { | ||||
|             "type": "absoluteYearly", | ||||
|             "interval": 1, | ||||
|             "month": 4, | ||||
|             "dayOfMonth": 26 | ||||
|         }, | ||||
|         "range": { | ||||
|             "type": "noEnd", | ||||
|             "startDate": "2023-04-26", | ||||
|             "endDate": "0001-01-01", | ||||
|             "recurrenceTimeZone": "UTC", | ||||
|             "numberOfOccurrences": 0 | ||||
|         } | ||||
|     } | ||||
| } | ||||
							
								
								
									
										56
									
								
								main.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										56
									
								
								main.py
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,56 @@ | ||||
| import requests | ||||
| import pandas as pd | ||||
| from neo4j import GraphDatabase | ||||
| 
 | ||||
| def createReporters(startMail: str): | ||||
|      | ||||
|     url = 'https://graph.microsoft.com/v1.0/users/' + startMail + '/directReports' | ||||
|     graph_result = requests.get(url=url, headers=headers) | ||||
|     if graph_result.status_code == 200: | ||||
|         with graphDB_Driver.session() as graphDB_Session: | ||||
|             for i in range(len(graph_result.json()["value"])): | ||||
|                 graphDB_Session.run("CREATE (u:USER {displayName: $displayName, id: $id, mail: $mail, title: $jobTitle, office: $officeLocation})",  | ||||
|                                     id=graph_result.json()["value"][i]['id'],  | ||||
|                                     displayName=graph_result.json()["value"][i]['displayName'],  | ||||
|                                     mail=graph_result.json()["value"][i]['mail'],  | ||||
|                                     jobTitle=graph_result.json()["value"][i]['jobTitle'], | ||||
|                                     officeLocation=graph_result.json()["value"][i]['officeLocation']) | ||||
|                 graphDB_Session.run("MATCH (a:USER {mail: $vorgesetzter}), (b:USER {mail: $mail}) CREATE (a)-[:vorgesetzter]->(b)", | ||||
|                                     mail=graph_result.json()["value"][i]['mail'],  | ||||
|                                     vorgesetzter=startMail) | ||||
|                 createReporters(graph_result.json()["value"][i]['mail']) | ||||
| 
 | ||||
| if __name__ == '__main__': | ||||
|     # Log in to online graph explorer: https://developer.microsoft.com/en-us/graph/graph-explorer and copy the access token | ||||
|     # the online graph explorer has an autocompletion | ||||
|     access_token = 'foobar' | ||||
|     headers = { | ||||
|         'Authorization': access_token | ||||
|     } | ||||
| 
 | ||||
|     # local neo4j Database | ||||
|     uri = "bolt://localhost:7687" | ||||
|     userName = "neo4j" | ||||
|     password = "org" | ||||
|     graphDB_Driver = GraphDatabase.driver(uri, auth=(userName, password))  | ||||
| 
 | ||||
|     startMail = 'Sascha.Daesler@crossnative.com' | ||||
|     #startMail = 'Mirko.Kuehne@crossnative.com' | ||||
|     url = 'https://graph.microsoft.com/v1.0/users/' + startMail | ||||
|     graph_result = requests.get(url=url, headers=headers) | ||||
| 
 | ||||
|     with graphDB_Driver.session() as graphDB_Session: | ||||
|         graphDB_Session.run("""CREATE (u:USER {displayName: $displayName,  | ||||
|                                                id: $id,  | ||||
|                                                mail: $mail,  | ||||
|                                                title: $jobTitle,  | ||||
|                                                office: $officeLocation})""",  | ||||
|                                 id=graph_result.json()['id'],  | ||||
|                                 displayName=graph_result.json()['displayName'],  | ||||
|                                 mail=graph_result.json()['mail'],  | ||||
|                                 jobTitle=graph_result.json()['jobTitle'], | ||||
|                                 officeLocation=graph_result.json()['officeLocation']) | ||||
|         print(graph_result.json()) | ||||
| 
 | ||||
|     createReporters(startMail) | ||||
| 
 | ||||
							
								
								
									
										5
									
								
								requirements.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								requirements.txt
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,5 @@ | ||||
| neo4j==5.5.0 | ||||
| pandas==1.5.3 | ||||
| requests==2.28.2 | ||||
| selenium==4.8.1 | ||||
| pyyaml | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user